I have an AMD cpu and I'm trying to run some code that uses Intel-MKL. The code is significantly slower than I expected.
I have an AMD cpu and I'm trying to run some code that uses Intel-MKL. The code is significantly slower than I expected.
As of 2021, Intel unfortunately removed the MKL_DEBUG_CPU_TYPE to prevent people on AMD use the workaround presented in the accepted answer. This means that the workaround no longer works, and AMD users have to either switch to OpenBLAS or keep using MKL.
To use the workaround, follow this method:
conda environment with conda's and NumPy's MKL=2019.MKL_DEBUG_CPU_TYPE = 5The commands for the above steps:
conda create -n my_env -c anaconda python numpy mkl=2019.* blas=*=*mklconda activate my_envconda env config vars set MKL_DEBUG_CPU_TYPE=5And thats it!
MKL_DEBUG_CPU_TYPE=5 then run your code.NOTE: I do not know the exact date or version when Intel removed the environment variable workaround.
FYI this slow down affects anything that uses Intel-MKL library and runs on AMD CPU (i.e. affects all operating systems and affects all programming languages and all programs (older versions of Matlab, C, C++, Python, Anaconda-Python, Machine-Learning like Tensorflow and Pytorch , again anything that uses Intel-MKL library on AMD CPU)).
FYI Setting and getting environment variables is out of scope for this question but here are some helpful links:
bash user who wants to set the environment variable just for their own user append the line export MKL_DEBUG_CPU_TYPE=5 to your user's .bashrc filep.s.