AWS Thinkbox Discussion Forums

Forcing Blender to use GPU

Deadline does not support GPU rendering for Blender as of today. There’s a hack that has been reported to work, I think it’s worth sharing here.

  1. Add a place in the submission script to inject command line arguments to the job. Then those arguments are passed to Blender’s executable/binary during the render.

To do that you’ll need to backup the existing and replace files from the attached archiveBlenderAdditionalArgs.zip (6.6 KB)
to:

"DeadlineRepository10\plugins\Blender\Blender.py"
"DeadlineRepository10\scripts\Submission\BlenderSubmission.py"

Remove files to revert, if required.

  1. After you’ve added the place to to add additional arguments to the submission script you’ll pass -P flag and provide the location of the script "/path/to/BlenderForceGPUScript.py"BlenderForceGPUScript.py (686 Bytes) and submit the job.

It should just work fine but if it does not repeat the same process and along with above step pass and extra argument after the script with a space in between them –debug-gpu

  1. If it still fails, please follow here: Troubleshooting — Deadline 10.1.22.4 documentation
4 Likes

Are you guys sure it doesn’t support GPU?

I’ve done some tests on a scene, if I render it directly from blender on CPU, it takes around 10min/frame. On GPU around 1 min/frame.

If I submit and render from deadline, it takes around 1min/frame, so I assume GPU rendering is working fine.

By the way, I was testing this, as I am searching for a way to pass my own .py script as an argument.

I have found that the attached submission scripts do not work. With or without filling in additional arguments, the error is the same.

=======================================================
Error
=======================================================
Failed after four attempts to copy "Blender.param". Please make sure that the file exists in the plugin directory.

=======================================================
Type
=======================================================
Exception

=======================================================
Stack Trace
=======================================================
   at Deadline.Plugins.PluginUtils.a(Job bfr, UserInfo bfs, SlaveSettings bft, DataController bfu)
   at Deadline.Plugins.PluginUtils.SyncFilesForJob(Job job, UserInfo jobUser, Boolean cleanup, String& message, SlaveSettings workerSettings, DataController dataController)
   at Deadline.Plugins.SandboxedPlugin.SyncFilesForJob(Job job, Boolean cleanup, String& message, CancellationToken cancellationToken)
   at Deadline.Slaves.SlaveRenderThread.e(String ajs, Job ajt, CancellationToken aju)
   at Deadline.Slaves.SlaveRenderThread.b(TaskLogWriter ajo, CancellationToken ajp)
   at Deadline.Slaves.SlaveRenderThread.a()

I tried looking into it myself, but my development knowledge is very limited, I couldn’t find anything.

Ok, after some snooping around, I found that there are 2 files in the standard plugins/Blender folder, called Blender.options and Blender.param, that also need to be copied to the custom/plugins/Blender folder in order for this to work.

Additionally, I have found that blender will only run the python script after rendering the file, because the -P argument is at the end of the command.

It should be placed instead after the .blend path argument.

If anyone else needs this, I have attached the modifier Blender.py script.

Blender.py (8.2 KB)

2 Likes

Hello @Sergiu_Hulpe

Thanks for sharing the workaround. I’ll update my internal records.

Thanks for sharing - I was able to get Deadline to render on GPU with Blender.
But now i want to force deadline to use the OPTIX instead of CUDA.
The Problem is - I don’t know where to put in the -P Flag.
I put it in the additional arguments box but i think it didn’t work.
(also put in the BlenderForceGPUScript.py OPTIX instead of CUDA)
bpy.context.preferences.addons[‘cycles’].preferences.compute_device_type = ‘OPTIX’

Screenshot 2022-04-21 215718

Thanks for helping :heart:

Hi Marcus,

I am doing something similar to you, with loading starting a script, I am submitting the job straight from python, and it looks like this:

1 Like

added a comment below, not sure if you will get notified without me replying :smiley:

for some reason GPU rendering worked for me Out of the box on 2 windows machines running 3.1 with optix, just macOS not doing what I want, they just started supporting METAL anyone got this running? got some dual vega cards doing nothing.

1 Like

I’ve been searching whether it’s possible to submit Blender GPU Cycles, there are plenty of old threads then I finally found this one! Thanks for sorting this

Can confirm this works on multi-gpu boxes and without it the jobs revert to CPU, will this be rolled out as a standard?

Thanks
Ant

I can confirm that it works! the only option is to make 2 files to switch between CUDA and OPTIX ?
Also it works with multigraphics!!

Hello again, I have edited the script to automatically fill in the path \ for the user, but when I call it I get one and I don’t know how to solve it.

Hello @Sergic

Apologies for late reply here.
It’s Python escaping slashes. Try to use it like this \\192.168… and then two slashes instead of one in the whole path.

He Ant

I know this reply is super late sorry about that. I do not think this can be added to standard submission scripts because these arguments are optional. Any command line argument can be passed here.

The actually functionality should be built to add support for GPU natively in the submission script. We already have a feature request for that.

If just that, I have it on the left side I call that line of code but it comes back with a / when I run the blender submit, I would like it to appear directly with //

Hello!

I have cleaned up the patch we had posted above, it was not working for me as well. The patch still has the same BlenderForceGPUScript.py file, but not is hardcoded to add the “-P” while rendering.
Attaching the zip file here, and the steps used to force GPU rendering with Blender:

  1. Replace your Blender application plugin files.
    Copy the Blender folder from the Step 1 folder into DeadlineRepository10\custom\plugins

  2. Replace the Blender submitter in the Monitor
    Copy the BlenderSubmission.py file from the Step 2 folder into DeadlineRepository10\custom\scripts\Submission

  3. When you’re submitting your job that needs to have GPU rendering enforced, add path to the “BlenderForceGPUScript.py” at the bottom of the submitter “Path to BlenderForceGPU Script” option.

Just make sure the Worker will be able to run BlenderForceGPUScript.py (included in the Step 3 folder) from wherever you’ve chosen to store it.

Updated Blender plugin files and it works fine with Deadline 10.3.0.x.
BlenderGPU Steps.zip (9.9 KB)

2 Likes

Hello, I had some questions about the installation of the scripts
When we move the step 1 and step 2 files, how does deadline know that it will look for the blender custom plug-in ? I had a last question to automate the addition of the force script BlenderForceGPUScript.py
thank you in advance for your answer

thank you very much for sharing the resources

For me it seems to work straight away, or am I missing anything?

Setup: Sending from Mac (Metal) to a PC with dual 3090 Tis using OptiX, both using Blender 3.4.

Does your code make it so we can’t add any other additional arguments anymore?

@Orage_studio, the custom folder gets the priority over the actual plugin/scripts folder in the Repository. So any customization stored under the custom folder would be pulled first and also survive the upgrade.

@sirhaffy, did you spend sometime on setting up the Blender as explained in the above threads? Share the logs or the error you ran into while setting up Blender GPU rendering.

@erlan_nephilim, you can add more arguments to Blender command-line using the submitter Additional Arguments. It will append those arguments to the Blender.

Privacy | Site terms | Cookie preferences