2
$\begingroup$

Using Blender's Network Render addon, I am trying to render on a client's GPU using this script:

import bpy

FlagCUDA = False

#Select CUDA
try:
    bpy.context.user_preferences.system.compute_device_type = 'CUDA'
    FlagCUDA = True
except:
    print("No CUDA-Device")
    FlagCUDA = False

if FlagCUDA:    
    try:
        bpy.context.user_preferences.system.compute_device = 'CUDA_MULTI_2'
    except:
        bpy.context.user_preferences.system.compute_device = 'CUDA_0'
#Check which GPUs are there
print("Rendering on: " + bpy.context.user_preferences.system.compute_device)

However, when I try to render it, the script doesn't seem to be run until after the slave has already rendered the file! For example, here's the slave's console output:

Created directory: /tmp/slave_1942577ae3d0b404da672d202b2a9a58
Created directory: /tmp/slave_1942577ae3d0b404da672d202b2a9a58/job_7
Fullpath /home/tylere/untitled.blend
File: untitled.blend and 0 other files
frame 1
Color management: using fallback mode for management
Read new prefs: /home/tylere/.config/blender/2.69/config/userpref.blend
read blend: /home/tylere/untitled.blend
Fra:1 Mem:7.10M (9.89M, Peak 16.99M) | Mem:0.00M, Peak:0.00M | Scene, RenderLayer | Synchronizing object | Cube
...
RenderLayer | Updating Images
Fra:1 Mem:7.11M (9.89M, Peak 17.00M) | Mem:0.00M, Peak:0.00M | Scene, RenderLayer | Updating Camera
Fra:1 Mem:7.11M (9.89M, Peak 17.00M) | Mem:0.00M, Peak:0.00M | Scene, RenderLayer | Updating Objects
Fra:1 Mem:7.11M (9.89M, Peak 17.00M) | Mem:0.00M, Peak:0.00M | Scene, RenderLayer | Updating Objects | Copying Transformations to device
Fra:1 Mem:7.11M (9.89M, Peak 17.00M) | Mem:0.00M, Peak:0.00M | Scene, 
...
RenderLayer | Path Tracing Tile 134/135
Fra:1 Mem:7.11M (9.89M, Peak 17.07M) | Mem:0.51M, Peak:0.59M | Scene, RenderLayer | Path Tracing Tile 135/135
Fra:1 Mem:7.11M (9.89M, Peak 17.07M) | Mem:0.02M, Peak:0.59M | Scene, RenderLayer | Finished
Fra:1 Mem:7.08M (9.89M, Peak 17.07M) Sce: Scene Ve:0 Fa:0 La:0
Saved: /tmp/slave_1942577ae3d0b404da672d202b2a9a58/job_7/000001.exr Time: 00:01.44 (Saving: 00:00.09)

No CUDA-Device
Rendering on: CPU

Blender quit
status 0

(The client I am currently testing scripts on has no GPU, hence the "No CUDA-Device")

How do I get the script to run BEFORE the rendering occurs on the slave?

$\endgroup$
1
  • $\begingroup$ I just found this fork of the Netrender add-on that allows setting slaves to specify their compute device (and a few other options). I haven't tried it yet, but it looks promising! $\endgroup$
    – celloman
    Commented Nov 19, 2015 at 22:58

1 Answer 1

1
$\begingroup$

I expect it is the way the addon runs. The python script is in control as it reads the file and starts rendering, only after it has finished does blender sit idle and go back to running registered text blocks from the open file step.

First I would suggest you setup the slaves to always start with gpu rendering enabled.

Failing that, you could adjust the netrender addon on each slave. You will find in netrender/operator.py that rendering starts either on line 80 or 97 you could specifically run your script before the render step or add your gpu enable code to the addon.

text = bpy.data.texts['myStartscript.py']
if text is not None:
    exec(compile(text.as_string(), 'errors.log', 'exec'))
 bpy.ops.render.render('INVOKE_AREA', animation=True)
$\endgroup$
3
  • $\begingroup$ "First I would suggest you setup the slaves to always start with gpu rendering enabled." How does one do this? Thanks for the other tips. $\endgroup$ Commented Oct 26, 2015 at 2:37
  • $\begingroup$ Start blender, adjust settings and save user settings. Come to think of it, you may be able to start the slave with a shell script that has blender -P startGPU.py so your script enables gpu as you start the slave. $\endgroup$
    – sambler
    Commented Oct 26, 2015 at 3:52
  • $\begingroup$ Rendering on gpu isn't a user setting though, CUDA user setting just adds gpu as an option $\endgroup$ Commented Oct 26, 2015 at 3:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .