GPU could not be enabled in blender 3.0
Closed this issue ยท 6 comments
Hi:
Many thanks for your help on blender 3.0 docker images.
Recently we have been working on upgrading the docker image, but somehow we failed to run it in CUDA mode(which do work with blender 2.9* images).
We want to enable GPU with the following function(which works before):
def enable_gpus():
cycles_addon = bpy.context.preferences.addons['cycles']
cycles_addon.preferences.compute_device_type = 'CUDA'
bpy.context.scene.render.engine = "CYCLES"
bpy.context.scene.cycles.device = "GPU"
But we don't why, bpy.context.preferences.addons['cycles'].preferences.devices
returns an empty list. as a result , we are not managed to change compute_devide_type.
As a workaround, we run blender 3.0 in graphics mode, and edit => preference => system, choosing CUDA manually. then we are able to see more than 1 devices in bpy.context.preferences.addons['cycles'].preferences.devices
Thanks for the information @fzlee ๐
Would you be able to provide a little more information about this issue? OS / Docker run command / how to replicate
Also would you mind trying to set the GPU devices using this snippet to see if that helps?
One thing that could potentially be related is the CUDA version (was reading the requirement for building Blender and it seems to point to CUDA Toolkit 11.4, 11.3, 11.2 or 11.1 here).
Just pushed an updated image for Blender 3.0 GPU here - @fzlee @Shrhawk Would you be able to test building this image to see if that solves this issue?
Hi juniorxsound:
Many thanks for your help on this.
Sorry for the late reply, we tried this push, but unfortunately, we are still not able to enable GPU.
Regarding to the former question:
OS: Ubuntu 2004
How to replicate: just run the newest docker image, and invoke the following pieces of code
def enable_gpus():
cycles_addon = bpy.context.preferences.addons['cycles']
cycles_addon.preferences.compute_device_type = 'CUDA'
bpy.context.scene.render.engine = "CYCLES"
bpy.context.scene.cycles.device = "GPU"
and you will see bpy.context.preferences.addons['cycles'].preferences.devices
returns an empty list.
HI @fzlee i managed enable GPU with latest Blender 3.0 image, here is the additional setting beside of yours:
# Enable CUDA
pref = bpy.context.preferences
cycles_addon = pref.addons["cycles"]
cpref = cycles_addon.preferences
cpref.compute_device_type = "CUDA"
cpref.compute_device = "CUDA_0"
# Enable and list all devices, or optionally disable CPU
print("----------------------------------------------")
cpref.get_devices()
for d in cpref.devices:
d.use = True
if d.type == "CPU":
d.use = False
print("Device '{}' type {} : {}" . format(d.name, d.type, d.use))
```
@indiejoseph many thanks for your help , it did help!