[Numpy-discussion] Numpy 1.7.0 with Intel MKL

QT rdirective at gmail.com
Sun Mar 10 21:24:59 EDT 2013

Dear all,

I'm at my wits end.  I've followed Intel's own
how to compile Numpy with Intel MKL.  Everything compiled and linked
fine and I've installed it locally in my user folder...There is one nasty
problem.  When one calls the numpy library to do some computation, it does
not use all of the available threads.  I have 8 "cores" on my machine and
it only uses 4 of them.  The MKL_NUM_THREADS environmental variable can be
set to tune the number of threads but setting it to 8 does not change
anything.  Indeed, setting it to 3 does limit the threads to 3....What is
going on?

As a comparison, the numpy (version 1.4.1, installed from yum, which uses
BLAS+ATLAS) uses all 8 threads.  I do not get this.

You can run this test program

python -mtimeit -s'import numpy as np; a = np.random.randn(1e3,1e3)'
'np.dot(a, a)'

There is one saving grace, the local numpy built with MKL is much faster
than the system's numpy.

I hope someone can help me.  Searching the internet has been fruitless.


My site.cfg for numpy (1.7.0)
library_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =

I've edited line 37 of numpy/distutils/intelcompiler.py
self.cc_exe = 'icc -O3 -fPIC -fp-model strict -fomit-frame-pointer -openmp
-parallel -DMKL_ILP64'

Also line 54 of numpy/distutils/fcompiler/intel.py
return ['-i8 -xhost -openmp -fp-model strict']

My .bash_profile also contains the lines:
source /opt/intel/bin/compilervars.sh intel64
source /opt/intel/mkl/bin/mklvars.sh intel64

The above is needed to set the LD_LIBRARY_PATH so that Python can source
the intel dynamic library when numpy is called.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20130310/111e4611/attachment.html>

More information about the NumPy-Discussion mailing list