... | @@ -2,7 +2,7 @@ |
... | @@ -2,7 +2,7 @@ |
|
|
|
|
|
As explained in the ["Monitoring Resources"](/monitoring) page, it is your responsibility to make sure that you are not monopolizing the entire CPUs of a server. This page lists a set of tricks to limit the number of CPU threads used by your scripts, when using common applications and libraries.
|
|
As explained in the ["Monitoring Resources"](/monitoring) page, it is your responsibility to make sure that you are not monopolizing the entire CPUs of a server. This page lists a set of tricks to limit the number of CPU threads used by your scripts, when using common applications and libraries.
|
|
|
|
|
|
## Limiting CPU Threads with OpenMP
|
|
## Limiting CPU Threads in 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.
|
|
[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.
|
|
|
|
|
... | @@ -16,6 +16,17 @@ The example above limits the number of threads to 8. You can change this to any |
... | @@ -16,6 +16,17 @@ The example above limits the number of threads to 8. You can change this to any |
|
|
|
|
|
Most graphical IDEs that support remote deployment (see ["Remote Code Deployment"](/remote-code)) also allow you to set environment variables in the remote host. For example, in PyCharm by JetBrains, this is achieved by modifying the "Run Configuration" of your script. Check the documentation of your IDE for more details.
|
|
Most graphical IDEs that support remote deployment (see ["Remote Code Deployment"](/remote-code)) also allow you to set environment variables in the remote host. For example, in PyCharm by JetBrains, this is achieved by modifying the "Run Configuration" of your script. Check the documentation of your IDE for more details.
|
|
|
|
|
|
|
|
## Limiting CPU Threads in OpenBLAS
|
|
|
|
[OpenBLAS](https://github.com/xianyi/OpenBLAS/wiki) is another common parallel programming library, used for example by Numpy. Limiting the number of threads works similarly to OpenMP, but with a different environmental variable. For example:
|
|
|
|
```
|
|
|
|
export OPENBLAS_NUM_THREADS=8
|
|
|
|
```
|
|
|
|
See this [link](https://github.com/xianyi/OpenBLAS#setting-the-number-of-threads-using-environment-variables) for more details.
|
|
|
|
|
|
## Other Tools and Libraries
|
|
## 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.
|
|
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.
|
|
|
|
|
|
|
|
## Credits
|
|
|
|
|
|
|
|
Thanks to Francesco Daghero for contributing to this page. |