- 1 year ago
How to limit number of threads used by NumPy's OpenBlas on Windows?
To limit the number of threads used by NumPy's OpenBLAS library on Windows, you can set the OPENBLAS_NUM_THREADS
environment variable before running your Python script or launching the Python interpreter. Here's how you can do it:
Open the command prompt: Press the Windows key, type "cmd," and press Enter to open the command prompt.
Set the environment variable: In the command prompt, enter the following command to set the
OPENBLAS_NUM_THREADS
environment variable:arduinoset OPENBLAS_NUM_THREADS=n
Replace
n
with the desired number of threads you want to limit. For example, to limit it to 4 threads, useset OPENBLAS_NUM_THREADS=4
.Note: This change is temporary and applies only to the current command prompt session. If you want to set the variable permanently, you can set it in the system's environment variables.
Run your Python script: Once the environment variable is set, you can run your Python script or launch the Python interpreter from the same command prompt. NumPy's OpenBLAS library will now use the specified number of threads.
By limiting the number of threads used by OpenBLAS, you can control the parallelism and potentially manage the computational resources more effectively.