3
$\begingroup$

Is there a way to configure the Blender Render or Cycles to use all the available cores in the machine except for one (or N) of them? I'd like to set a render off in the background but leave me with a core to catch up on emails, browse, etc.?

I've tried using a fixed number of cores for rendering but this means if I swap the blend file between machines from, say a 6 core machine to a 12 core machine, then I have to manually reconfigure how many cores to use.

Thanks

$\endgroup$
1
  • $\begingroup$ This might be possible through drivers, but I am not a driver wizzard so I will leave that to someone else. $\endgroup$ – PGmath Jan 19 '16 at 16:09
6
$\begingroup$

You will have to have a script file in each of your blends containing this:

import bpy
from multiprocessing import cpu_count

cores_idle = 1    # <- SET THIS

# cpu_count() returns logical cores not physical
cores_available = cpu_count()
cores_enabled = max(1, cores_available - cores_idle)

for scene in bpy.data.scenes:
    scene.render.threads_mode = 'FIXED'
    scene.render.threads = cores_enabled

Give it a .py extension and check register so it is run by blender when you open the file (this should be also enabled in Preferences). You can also save this script into your Start Up file CtrlU.

Or for rendering you can execute it from the command line with --python, without having to modify your startup or .blend files.

$\endgroup$
3
  • $\begingroup$ Don't you need to add the register and unregister functions? $\endgroup$ – someonewithpc Jan 19 '16 at 20:04
  • $\begingroup$ That's only needed for add-ons. $\endgroup$ – ideasman42 Jan 19 '16 at 20:52
  • $\begingroup$ @someonewithpc nope, it's enough that it get's run. We don't need to register panels classes etc. $\endgroup$ – Jaroslav Jerryno Novotny Jan 19 '16 at 20:52
2
$\begingroup$

There is a very simple way to do this, if you don't care about reading it per computer. If you want it to be done automatically, see the other answer. (yes, I made this before I read your whole question.) :P

  1. Scroll down the render panel to the performance section.
  2. Select fixed threads
  3. Change the number of threads to the number you would like.

The illustration below shows the cpu used by each thread over the render of two frames.

enter image description here

Keep in mind about this method.

  • This method is based on threads, not cores.
  • It will not always choose the same, or last thread of your pc to deactivate.
  • The "auto-detect" method will use all threads.
  • The tread you have chosen to leave out will still work, because now it is running the rest of the processes on your computer.
  • During the render of a single frame, the "dormant" thread may change.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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