3
$\begingroup$

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?

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

2 Answers 2

4
$\begingroup$

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
print(prefs.compute_device_type)

for d in prefs.devices:
    print(d.name)
$\endgroup$
0
$\begingroup$

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"
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .