Skip to content Skip to sidebar Skip to footer

Unintended Multithreading In Python (scikit-learn)

I'm using mixture submodule of sklearn module for Gaussian Mixture Model... When I run my code on a multicore system, it uses multiple cores even though I do not ask for it in the

Solution 1:

If you are using MKL then try

export MKL_NUM_THREADS=1

For Numpy with OpenBLAS:

export OPENBLAS_NUM_THREADS=1

For some versions of Numpy this variation has been suggested:

export NUMEXPR_NUM_THREADS=1

The environment variable has to be set before the script is run (setting inside the script itself does not have the desired effect). For setting threads at runtime see: Set max number of threads at runtime on numpy/openblas

See the following for identifying how your numpy is setup: How to check blas/lapack linkage in numpy/scipy?

Solution 2:

thanks @prgao

the answer is there Python: How do you stop numpy from multithreading?

setting "export MKL_NUM_THREADS=1" seems to be working

Post a Comment for "Unintended Multithreading In Python (scikit-learn)"