SUMMARY
This article provides information on how you can limit the number of threads being used by Nuke using Python 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 does not limit how many threads it will use, so will use what CPU threads it can. This can allow Nuke to use a lot of CPU resources, which can cause issues on some machines.
If you're encountering performance issues when using Nuke then sometimes 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: Limiting threads in Nuke with the -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 user directory. The default location for the .nuke directory on each platform is:
- Windows: C:\Users\<username>\.nuke
- MacOS: /Users/<username/.nuke
- Linux: /home/<username>/.nuke
Further information about where to locate your .nuke directory an also be found in our Q100048: Locating the default .nuke directory article.
Please also see Loading Gizmos, NDK Plug-ins, and Python and Tcl Scripts in the Nuke's online documentation for more information about the .nuke directory, as well as 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 and set a value for nuke.env['threads']
. 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: If you do not already have an init.py file, you will need to create one and more information about this can be found here: Q100490: What are the init.py and menu.py startup script files
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 Developer's Guide for Nuke.
We're sorry to hear that
Please tell us why