Skip to content

blender server doesn't actively make use of GPU #62

@SeanCurtis-TRI

Description

@SeanCurtis-TRI

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"] = 1

This 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions