Since you're runnning Linux and Nvidia GPU, you can use nvidia-smi
and a simple bash script to see what is occupying your Nvidia graphics card at the moment, and pause your rendering accordingly.
My code is based on grep
regular expressions matching the rendering process you want to be of idle priority and the rest of the Blender CUDA jobs.
I've come up with a Bash one-liner that does the job for me:
while [ True ]; do nvidia-smi | grep ".*[1-9]*.*C.*blender" | grep -v $(pgrep -f "blender Idle_Animation.blend") && { pkill -SIGSTOP -f "blender Idle_Animation.blend"; echo "pause"; } || { pkill -SIGCONT -f "blender Idle_Animation.blend"; echo "go"; }; sleep 5s; done
How this works?
- It loops forever
- Runs
nvidia-smi
that returns a nice table with processes using the GPU
- It uses
grep
to find blender processes that use the CUDA functionality
- It uses
grep
again with a -v
switch to exclude the IDLE process from the search
- If there's anything left after that filtering it'll send
SIGSTOP
to all blender processes matching "blender Idle_Animation.blend" command
- If not - it'll send a
SIGCONT
effectively un-pausing (or doing nothing if they weren't stopped) all IDLE processes
- It waits 5 seconds before checking again
You need to just replace the "blender Idle_Animation.blend" with whatever string that'll identify your idle rendering processes. The pgrep -f
will analyze the full command used to start a process, so if you run blender -b Idle_Animation.blend -a
you can use exactly the same string to identify all processes belonging to that job.