-
Notifications
You must be signed in to change notification settings - Fork 11
Description
When running the blender server and rendering against the Cycles renderer, I found that the default configuration was CPU bound. Within blender, I could configure blender's preferences to use GPU (which makes a huge performance difference).
Following the guidance from this stackoverflow question, I was able to introduce a --bpy_settings_file with the following code:
if bpy.data.scenes[0].render.engine == "CYCLES":
cycles_prefs = bpy.context.preferences.addons["cycles"].preferences
cycles_prefs.compute_device_type = "CUDA"
bpy.context.scene.cycles.device = "GPU"
bpy.context.preferences.addons["cycles"].preferences.get_devices()
for d in cycles_prefs.devices:
d["use"] = 1This successfully changed the rendering to be GPU accelerated.
Ideally, the server should be doing this for us.
Naively, we could simply stash this code into the server. At this point, it's not clear if that could be harmful:
- What if the user has a card where "OPTIX" acceleration would be better than "CUDA"?
- What if the user has a driver problem?
We might consider simply adding the code stanza and including a flag called --disable_auto_gpu. It would at least allow a user to opt-out if it doesn't do what they want.
Finally, the stanza above is a bit of black magic incantation, it probably bears a bit more investigation to discover if it's all necessary/helpful.