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

Forcing Blender Cycles to use GPU #78

Open
1 task done
jrsndl opened this issue Nov 26, 2024 · 2 comments
Open
1 task done

Forcing Blender Cycles to use GPU #78

jrsndl opened this issue Nov 26, 2024 · 2 comments
Labels
sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Comments

@jrsndl
Copy link

jrsndl commented Nov 26, 2024

Is there an existing issue for this?

  • I have searched the existing issues and added correct labels.

Please describe the feature you have in mind and explain what the current shortcomings are?

Blender Cycles using GPU is very useful for fast turnarounds. The speedup is tenfold or more on many scenes.
Forcing Blender to use GPU on renderfarm for Cycles is not strightforward.
I suggest Ayon should support Deadline render submissions with forced GPU.

It seems the workaround is to execute Python script on each render node before render starts with Blender -P command line option.

See long thread on AWS forum.

Suggested implementation?

The ForceGPU.py from the AWS forum post, modded by AWS staff (the autotile addon might be skipped):

import bpy

bpy.context.preferences.addons['cycles'].preferences.compute_device_type = 'CUDA'

#calling get_devices() first will populate the devices list
#otherwise the script might find it empty, even when compatible devices are present
bpy.context.preferences.addons['cycles'].preferences.get_devices()
bpy.context.preferences.addons['cycles'].preferences.devices[0].use= True

bpy.context.scene.cycles.device = 'GPU'

#Use auto tile size to automatically set the tile size
#that better takes advantage of your GPU
bpy.ops.preferences.addon_enable(module="render_auto_tile_size")
bpy.context.scene.ats_settings.is_enabled = True

bpy.ops.render.render(animation=True)

See also the post from reecemuller on Ynput forum.

Describe alternatives you've considered:

No response

@BigRoy
Copy link
Contributor

BigRoy commented Dec 3, 2024

I assume, on the farm, that Blender still runs the full startup scripts of AYON - right? If so, I think we're better off doing this differently. We could e.g. submit along an environment variable to the farm job:

AYON_BLENDER_CYCLES_FORCE_GPU=1

And have startup logic that if that is set that it forces those addon preferences to be set as the user requested. That way, I don't think we need to change any Deadline-related logic? (And potentially even better; the logic may transfer to other renderfarms?)

If Blender, when rendering on farm does not trigger the usual pipeline startup scripts (like installing AYON Host) then we might need to look into other options, yes.

@BigRoy BigRoy added type: enhancement Improvement of existing functionality or minor addition community Issues and PRs coming from the community members sponsored This is directly sponsored by a client or community member and removed community Issues and PRs coming from the community members labels Dec 3, 2024
@BigRoy BigRoy changed the title Forcing Blender to use GPU Forcing Blender Cycles to use GPU Dec 3, 2024
@jrsndl
Copy link
Author

jrsndl commented Dec 4, 2024

It looks to me that Ayon launch is not connected to deadline cmd. We need to add the -P option to the deadline arguments somehow.

I can mod the deadline blender plugin and add the -P file.py depending on the environment. Maybe The vanila Deadline 10.4 Blender Plugin has no -P render argument, so I think no way around that, anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

No branches or pull requests

2 participants