Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Where to find the mkl_lapack lib

Andreas_M_
Beginner
2,065 Views

Hi, I'm trying to compile numpy for python 3.4 with Intel MKL on Mac OS X. In this process I have solved many problems myself, but I'm stuck on this one:

icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -dynamiclib -L/opt/intel/lib/intel64 -L/opt/intel/lib -L/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib -lpython3.4 build/temp.macosx-10.9-x86_64-3.4/numpy/linalg/lapack_litemodule.o build/temp.macosx-10.9-x86_64-3.4/numpy/linalg/lapack_lite/python_xerbla.o -L/opt/intel/mkl/lib -Lbuild/temp.macosx-10.9-x86_64-3.4 -lmkl_lapack -lmkl_rt -lpthread -o build/lib.macosx-10.9-x86_64-3.4/numpy/linalg/lapack_lite.so
ld: library not found for -lmkl_lapack
ld: library not found for -lmkl_lapack 

So the question is, what directory do I need to add for the above to work. This is what I have in my mkl/lib directory:

pwd # /opt/intel/composer_xe_2013_sp1.1.103/mkl/lib
ls #
libmkl_avx.dylib          libmkl_intel_ilp64.dylib  libmkl_mc.dylib           libmkl_vml_avx2.dylib
libmkl_avx2.dylib         libmkl_intel_lp64.a       libmkl_mc3.dylib          libmkl_vml_mc.dylib
libmkl_blas95.a           libmkl_intel_lp64.dylib   libmkl_p4m.dylib          libmkl_vml_mc2.dylib
libmkl_blas95_ilp64.a     libmkl_intel_sp2dp.a      libmkl_p4m3.dylib         libmkl_vml_mc3.dylib
libmkl_blas95_lp64.a      libmkl_intel_sp2dp.dylib  libmkl_p4p.dylib          libmkl_vml_p4m.dylib
libmkl_core.a             libmkl_intel_thread.a     libmkl_pgi_thread.a       libmkl_vml_p4m2.dylib
libmkl_core.dylib         libmkl_intel_thread.dylib libmkl_rt.dylib           libmkl_vml_p4m3.dylib
libmkl_intel.a            libmkl_lapack95.a         libmkl_sequential.a       libmkl_vml_p4p.dylib
libmkl_intel.dylib        libmkl_lapack95_ilp64.a   libmkl_sequential.dylib   locale
libmkl_intel_ilp64.a      libmkl_lapack95_lp64.a    libmkl_vml_avx.dylib

The above comes from installation of Intel Composer XE 2013 SP 1.1.103

Please note that I can't use the -mkl flag since that does too much. 

I can consistently reproduce this by execution this script:

wget https://pypi.python.org/packages/source/n/numpy/numpy-1.8.1.tar.gz#md5=be95babe263bfa3428363d6db5b64678
tar -xf numpy-1.8.1.tar.gz
cd numpy-1.8.1

cat > site.cfg <<EOF
[mkl]
library_dirs = /opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib
include_dirs = /opt/intel/include:/opt/intel/include/intel64:/opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs = mkl_lapack
EOF

export PYLINK="import sys; import os; print('-L' + os.path.abspath(os.__file__ + '/../..') + ' -lpython3.' + str(sys.version_info[1]))"

patch numpy/distutils/intelccompiler.py <<EOF
--- intelccompiler_old.py	2014-07-04 19:27:02.000000000 +0200
+++ intelccompiler.py	2014-07-04 19:27:46.000000000 +0200
@@ -36,10 +36,10 @@
     cc_args = "-fPIC"
     def __init__ (self, verbose=0, dry_run=0, force=0):
         UnixCCompiler.__init__ (self, verbose, dry_run, force)
-        self.cc_exe = 'icc -m64 -fPIC'
+        self.cc_exe = 'icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost'
         compiler = self.cc_exe
         self.set_executables(compiler=compiler,
                              compiler_so=compiler,
                              compiler_cxx=compiler,
                              linker_exe=compiler,
-                             linker_so=compiler + ' -shared')
+                             linker_so=compiler + ' -dynamiclib $(python3 -c $PYLINK)')
EOF

python3 setup.py config --compiler=intelem
python3 setup.py build --compiler=intelem
python3 setup.py install
0 Kudos
1 Solution
Gennady_F_Intel
Moderator
2,065 Views

You don't need to link with libmkl_lapack.*. You need to link with mkl_rt only. Please look at this article - https://software.intel.com/en-us/articles/using-intel-mkl-in-your-python-programs.

 

View solution in original post

0 Kudos
2 Replies
mecej4
Honored Contributor III
2,065 Views

There is no such library (libmkl_lapack.a or libmkl_lapack.so) included in the current version of MKL, nor is such a library needed. Recent versions of MKL do not separate BLAS, LAPACK, etc., routines into distinct libraries.

Use the MKL link line advisor ( https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor ) to find which libraries you should include. You will probably receive something along the lines of "-L$(MKLROOT)/lib -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -lpthread -lm"

0 Kudos
Gennady_F_Intel
Moderator
2,066 Views

You don't need to link with libmkl_lapack.*. You need to link with mkl_rt only. Please look at this article - https://software.intel.com/en-us/articles/using-intel-mkl-in-your-python-programs.

 

0 Kudos
Reply