Hey there,
we use blender on our renderfarm “Royalrender”.
There is a script started at cmd line, which enables all gpus for rendering.
It doesn’t work, so far I think, blender can only enable gpus when the gui is loaded.
Strange is, that the script actually changes the settings (when I save with: bpy.ops.mw.save_userpref()), but doesn’t use the selected gpus in nongui mode.
Really strange is, that when I start blender with gui and then save the userprefs manually, the script works, BUT only on this specific machine.
When copying this generated userpfref to all clients, it doens’t work. (Same Hardware)
So I have to generate userprefs for every client manually. Looks like every userpref, has a unique ID, or the gpus have unique IDs.
Does someone know this problem? Please Help
import bpy
import addon_utils
print("RR - enable cycles GPU at startup")
import bpy
scene = bpy.context.scene
scene.cycles.device = 'GPU'
prefs = bpy.context.preferences
cprefs = prefs.addons['cycles'].preferences
# Attempt to set GPU device types if available
for compute_device_type in ('CUDA', 'OPENCL', 'NONE'):
try:
cprefs.compute_device_type = compute_device_type
break
except TypeError:
pass
# Enable all CPU and GPU devices
for device in cprefs.devices:
device.use = True
bpy.ops.mw.save_userpref()