We have our own render queue manager at work, and i use a python script to set the compute device of each worker to GPU. However, with 2.79 the script no longer works.

Here is the script i use:

import bpy
bpy.context.user_preferences.system.compute_device_type = 'CUDA'
bpy.context.user_preferences.system.compute_device = 'CUDA_MULTI_2'

Pretty simple right? But in 2.79 i get the following error:

AttributeError: 'UserPerferencesSystem' object has no attribute 'compute_device_type'

Anyone knows what changed in 2.79 that causes this error?

  • $\begingroup$ your error message says that you try to access 'UserPerferencesSystem' instead of 'UserPreferencesSystem' which seems to be a typo? $\endgroup$ – Madlaina Kalunder Aug 15 '17 at 16:20

Changes have been made in the Blender API. You can retrieve 'compute_device_type' and 'devices' via the cycles addon preferences

prefs = bpy.context.user_preferences.addons['cycles'].preferences

for d in prefs.devices:

And as of version 2.81, it seems like the Blender API has once again changed, because @pistiwique's answer doesn't work for me. You can now use:

# Set the device_type
bpy.context.preferences.addons["cycles"].preferences.compute_device_type = "CUDA"

# Set the device and feature set
bpy.context.scene.cycles.device = "GPU"
bpy.context.scene.cycles.feature_set = "SUPPORTED"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.