I'm trying to enable GPU rendering on a headless linux machine. I'm using the following code:
print("----------------------------------------------")
print('setting up gpu ......')
bpy.context.scene.cycles.device = "GPU"
for scene in bpy.data.scenes:
print(scene.name)
scene.cycles.device = 'GPU'
bpy.context.preferences.addons["cycles"].preferences.compute_device_type = "CUDA"
bpy.context.preferences.addons["cycles"].preferences.get_devices()
print(bpy.context.preferences.addons["cycles"].preferences.compute_device_type)
bpy.context.preferences.addons["cycles"].preferences.get_devices()
for d in bpy.context.preferences.addons["cycles"].preferences.devices:
d.use = True
if d.type == 'CPU':
d.use = False
print("Device '{}' type {} : {}".format(d.name, d.type, d.use))
print('setting up gpu done')
print("----------------------------------------------")
and I got the result showing as follows:
----------------------------------------------
setting up gpu ......
Scene
CUDA
Device 'NVIDIA TITAN Xp' type CUDA : True
Device 'Intel Xeon CPU E5-2620 v4 @ 2.10GHz' type CPU : False
Device 'NVIDIA TITAN Xp' type OPTIX : True
setting up gpu done
----------------------------------------------
However, I found the rendering speed still very slow (similar to CPU rendering), and nvidia-smi showed that no processes were running.
My blender version is 3.3. Is anything wrong with my setup?