Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SeanCurtis-TRI opened this issue Aug 15, 2023 · 1 comment
Open

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

SeanCurtis-TRI opened this issue Aug 15, 2023 · 1 comment

Comments

@SeanCurtis-TRI
Copy link
Contributor

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.

@jwnimmer-tri
Copy link
Contributor

So long as "the user has the final say", I think it'd be OK to default to better GPU.

By "the user has the final say", I mean at least that the user's --bpy_settings_file is run last, so change anything they didn't like about our defaults.

Ideally, the *.blend file (--blend_file) would also trump our defaults, but I'm not sure if that's possible. Possibly it would undo our GPU settings unconditionally, even though the user didn't mean to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants