Unintended multithreading in Python (scikit-learn)

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?