I'm rendering an animation, but it's a low priority task. I want that rendering to pause every time I render something else and resume as soon as that's finished.

I just want to use all idle time of my GPU to render that animation, but prioritize other tasks.

I'm running Linux Mint and have an Nvidia GTX 960 GPU.

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?

  1. It loops forever
  2. Runs nvidia-smi that returns a nice table with processes using the GPU
  3. It uses grep to find blender processes that use the CUDA functionality
  4. It uses grep again with a -v switch to exclude the IDLE process from the search
  5. If there's anything left after that filtering it'll send SIGSTOP to all blender processes matching "blender Idle_Animation.blend" command
  6. If not - it'll send a SIGCONT effectively un-pausing (or doing nothing if they weren't stopped) all IDLE processes
  7. 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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.