... | ... | @@ -4,3 +4,17 @@ As explained in the ["Monitoring Resources"](/monitoring) page, it is your respo |
|
|
|
|
|
## Limiting CPU Threads with OpenMP
|
|
|
|
|
|
[OpenMP](https://www.openmp.org/) is a common shared-memory parallel programming library. For example, OpenMP is sometimes used by TensorFlow and PyTorch when training a model without GPU support.
|
|
|
|
|
|
If you find out that your code is using too many CPU threads, you can limit them setting the `OMP_NUM_THREADS` environment variable. On most command-line shells (e.g., bash, zsh, etc.) this is done with the following command:
|
|
|
|
|
|
```
|
|
|
export OMP_NUM_THREADS=8
|
|
|
```
|
|
|
|
|
|
The example above limits the number of threads to 8.
|
|
|
|
|
|
|
|
|
## Other Tools and Libraries
|
|
|
|
|
|
If you are currently working with another program or library that uses multi-threading, and you can share some code or some tips on how to limit the number of threads, please contact the sysadmins. We will be glad to add your suggestions to this page. |