3

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?

Joel
  • 61
  • 1
  • 4

2 Answers2

4

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)
pistiwique
  • 1,106
  • 9
  • 22
0

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"
Zorobay
  • 131
  • 4