Page MenuHome

Force GPU rendering python script
Open, NormalPublic

Description

In our quest to get our GPU workers to use all available GPU's we have found a script.

This script doesn't work when added to the script>startup directory. We don't know why.

But, when added to the commandline in the yaml file of the manager it works perfectly.

Add this to the commandline. --enable-autoexec --python "S:/-location script-/gpurender.py"

gpurender.py is below script.

# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>
import bpy
bpy.context.user_preferences.addons['cycles'].preferences.compute_device_type = 'CUDA'
bpy.context.user_preferences.addons['cycles'].preferences.compute_device = 'CUDA_MULTI_2'

Our request is to have this be added in the flamenco worker code or something. And have a checkbox somewhere to enable this feature..

We hope it helps!

With kind regards,
Dennis Teusink

Details

Type
Patch

Event Timeline

Dennis Teusink (Teus) triaged this task as Normal priority.

We are urgently need this feature

Something like this should work:

import bpy

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

prefs = bpy.context.user_preferences
cprefs = prefs.addons['cycles'].preferences

# Attempt to set GPU device types if available
for compute_device_type in ('CUDA', 'OPENCL', 'NONE'):
    try:
        cprefs.compute_device_type = compute_device_type
        break
    except TypeError:
        pass

# Enable all CPU and GPU devices
for device in cprefs.devices:
    device.use = True

Thanks @Brecht Van Lommel (brecht)!

@joel heethaar (joel_nl) I've added Brecht's script to Flamenco Worker, to the T53099-gpu-rendering branch, but I haven't created anything around that yet. Can you test that the script works by adding --enable-autoexec --python "/path/to/flamenco-worker/flamenco_worker/enable_all_gpus.py" to the blender variable in your flamenco-manager.yaml?

Adding the script to my blender variable in flamenco-manager.yaml works for me.

@Sybren A. Stüvel (sybren) I previously haven't had a chance to test this script properly. For now we are working with Backburner as our main render farm tool. We would like to use Flamenco though. But it is not very compatible with our Windows network. Everytime we try to work with Flamenco we run into strange issues.

I've tested this script though and it works fine. Now we need a checkbox or something in the Flamenco panel to activate it or something. Thanks...

@Sybren A. Stüvel (sybren) I previously haven't had a chance to test this script properly. For now we are working with Backburner as our main render farm tool. We would like to use Flamenco though. But it is not very compatible with our Windows network. Everytime we try to work with Flamenco we run into strange issues.

Please make sure that you have the latest Blender Cloud add-on 1.11.0 (just released) as it contains Windows and Blender 2.8 fixes. If you still see issues, please provide us with a proper bug report.

I've tested this script though and it works fine.

That is good to know.

Now we need a checkbox or something in the Flamenco panel to activate it or something. Thanks...

Why? As @A K (campino) said you can just add it to the Flamenco Manager config.

Dennis Teusink (Teus) added a comment.EditedJan 8 2019, 3:07 PM

Please make sure that you have the latest Blender Cloud add-on 1.11.0 (just released) as it contains Windows and Blender 2.8 fixes. If you still see issues, please provide us with a proper bug report.

We will.

I think the same problem is occurring as that path resolve thing here Projects on mapped network drives fail.

When i change the script location to a network drive and set the variable in the yaml file
windows: S:/!Apz/Blender/Flamenco Blender 2.79/Blender/Blender.exe --python //rackstation/software/!Apz/Blender/enable_all_gpus.py

it returns this.

OSError: Python file "C:\Users\Administrator\Desktop\flamenco-worker-2.1.0-windows\//RACKSTATION/software/!Apz/Blender/enable_all_gpus.py" could not be opened: No such file or directory

It doesn't matter if i use a drive letter, backslashes or forward slashes. If i put it between quotation marks, like in the documentation, the manager won't even run.

I recommend not using any exclamation marks in your path. Also only use mapped network drives (so S:/ instead of //rackstation/software), as // means something else to Blender. That, and of course T60131 should be fixed.

Also only use mapped network drives (so S:/ instead of rackstation/software), as means something else to Blender. That, and of course T60131 should be fixed.

That why i tried every which version i know of url. Nothing worked. This version was with the slashes...

I recommend not using any exclamation marks in your path.

Ok... That worked. Which is weird because the path to Blender itself also contains an exclamation mark. Don't know why it works but it does. so i'm happy. We are changing the structure of our Software/Install server anyway. It is a mess. This folder for instance is like 20 years old. :)

Thanks for all the help!