Create a ticket
Follow

Q100376: How to limit the number of threads Nuke always launches with using the init.py file

SUMMARY

This article provides information on how you can limit the number of threads being used by Nuke via the init.py file.  This is useful if you want to always limit Nuke to fewer threads than the total available on your machine.

 

MORE INFORMATION

By default, Nuke runs with as many threads as there are CPU cores on the device.  This will be the optimal setting for devices with a low core count but there may be some occasions where machines with high core count exhibit slower performance.

 

If you're encountering performance issues on a high core machine then it can be beneficial to lower the number of threads that Nuke runs with.  You can do this either by launching Nuke with a command line flag or by setting a python customisation in your init.py file.

 

Command line flag

You can limit the number of threads that Nuke uses by launching it from a terminal or command prompt with the -m flag.  This is useful when troubleshooting problems but if you always want to limit the number of threads it may not be convenient to always launch Nuke from a terminal or command prompt. 

 

Please see Q100117: Launching Nuke with limited number of threads (-m flag) for instructions on how to use the command line flag.

 

NOTE: The -m flag overrides the setting listed in the init.py file.

 

Python customisation in your init.py file

Alternatively you can use Nuke's python API to limit the number of thread Nuke launches with by adding a command to the init.py file in your .nuke directory in your home area.  The default location for the .nuke directory on each platform is:

  • Windows: C:\Users\<username>\.nuke
  • MacOS: /Users/<username/.nuke
  • Linux: /home/<username>/.nuke

Please see Loading Gizmos, NDK Plug-ins, and Python and Tcl Scripts in the Nuke Online Help for more information about the .nuke directory and other locations that are scanned on start up for Nuke customisations.

 

To set a thread limit for Nuke, open your init.py file with a text editor (if you do not already have an init.py file then create this as a plain text file with a .py extension) and set a value for nuke.env['threads'] at the end of the file.  For example, to always launch with 8 threads you would add

nuke.env['threads'] = 8 

 

The next time you run Nuke it will launch with your specified number of threads.

 

NOTE: Launching Nuke from a command prompt or terminal with the -m flag will override your new value.

 

 

FURTHER READING

More information on start-up scripts can be found in the Configuring Nuke section of the Nuke User Guide and in the Python Developers guide for Nuke.

 

Was this article helpful?
/

We're sorry to hear that!

Please tell us why.
0 out of 0 found this helpful