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

Runtime error of numpy in MKL 11.1 on 32bit Linux

ASTTools
Beginner
558 Views

We built quite a number of packages with various versions of Intels compilers. Currently we are facing a problem during the port of numpy v1.4.1 with Intel compilers and MKL 11.1.059 on RHEL 3 update 9 for 32bit.

One library target within the numpy package, the python extension lapack_lite.so, depends on MKL. We've tried many combinations of MKL libraries i.e. mkl_core, mkl_sequential, iomp5, guide, The best case scenario is that import numpy works, but at latest we get a crash when running tests related to lapack library and MKL itself. We even tried to link lapack_lite.so manually and used the link line from Intels MKL link line advisor, but got same problem again. The same happens, if we run 'numpy.test()'.

Python 2.5.1 (r251:54863, Apr 26 2010, 17:46:18)
[GCC Intel C++ gcc 3.2 mode] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy
>>> numpy.matrix([[1, 5, 10], [1.0, 3j, 4]], numpy.complex128).T.I.H

*** libmkl_p4m.so *** failed with error :
/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32/libmkl_p4m.so:
undefined symbol: mkl_dft_commit_descriptor_s_c2c_md_omp

*** libmkl_def.so *** failed with error :
/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32/libmkl_def.so:
undefined symbol: mkl_dft_commit_descriptor_s_c2c_md_omp

MKL FATAL ERROR: Cannot load neither libmkl_p4m.so nor libmkl_def.so


As you see beneath the mkl/lib/32 folder is in our LD_LIBRARY_PATH and thus despite of the error message above we expect that we are still doing something wrong at linktime. Which libraries out of MKL 11.1 should we link against our shared library lapack_lite.so?

Or might the problem originate in the way we linked the python executable? Anyway, we never had to link python itself against MKL and also didnt this time

Any help would be appreciated!



--------------------------------------------------------------------------------
further details
--------------------------------------------------------------------------------

The site.cfg file used to build numpy:

[mkl]

library_dirs = /share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32:

/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/lib/ia32

include_dirs = /share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/include

lapack_libs = mkl_lapack,

mkl_libs = mkl_solver, mkl_intel, mkl_intel_thread, mkl_core, iomp5

The link line for lapack_lite.so:

icc -shared build/temp.linux-i686-2.5/numpy/linalg/lapack_litemodule.o build/temp.linux-i686-2.5/numpy/linalg/python_xerbla.o -L/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32 -L/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/lib -Lbuild/temp.linux-i686-2.5 -lmkl_lapack -lmkl_solver -lmkl_intel -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lpython2.5 o build/lib.linux-i686-2.5/numpy/linalg/lapack_lite.so

The build command:

/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/bin/python

setup.py config --compiler=intel build_clib --compiler=intel build_ext --compiler=intel install --prefix=/share/astlib/temp/ia32-unknown-linux_r3i11/numpy-1.4.1

the $LD_LIBRARY_PATH:

/usr/local/lib:/share/astenv/devtools/bin/bin.ia32-unknown-linux:/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32:/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/lib:/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/lib/ia32

------------------------------------------------------------------------------

0 Kudos
5 Replies
barragan_villanueva_
Valued Contributor I
558 Views
Hi,

Please try Link Line Advisor at the top of MKL Forum for correct libraries to link (with -Wl,--start-group ... -Wl,--end-group brackets there)
0 Kudos
ASTTools
Beginner
558 Views

I've originally used the libraries from link-line-advisor, but did not use the --start/end-group linker options, because numpy's makesupport is using some python-scripts to derive thefinally used link line and I can only influence the list and order of used libraries. It would require extra efforts to get the link line set with the group options.

Therefore I tried manually to link with the group options and the situation improved, but it still didn't solve the issue. This is the new error we get at runtime:

------------------------------------------------------------------------

Python 2.5.1 (r251:54863, Apr 26 2010, 17:46:18) [GCC Intel C++ gcc 3.2 mode] on linux2 Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.matrix([[1, 5, 10], [1.0, 3j, 4]], numpy.complex128).T.I.H
Python-2.5.1/bin/python: relocation error:
/share/astenv/devtools/compilers/ia32-unknown-linux/intel/c11.1.059_f11.1.059/mkl/lib/32/libmkl_lapack.so:
undefined symbol: mkl_serv_lsame

-----------------------------------------------------------------------

This is the link line used to link lapack_lite.so:

icc -shared -sox
-L/share/astlib/temp/ia32-unknown-linux_r3i11/autoconf-2.59/lib
-L/share/astlib/temp/ia32-unknown-linux_r3i11/automake-1.9.6/lib
-L/share/astlib/temp/ia32-unknown-linux_r3i11/libtool-1.5.22/lib
-L/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/lib
-I/share/astlib/temp/ia32-unknown-linux_r3i11/autoconf-2.59/include
-I/share/astlib/temp/ia32-unknown-linux_r3i11/automake-1.9.6/include
-I/share/astlib/temp/ia32-unknown-linux_r3i11/libtool-1.5.22/include
-I/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/include
build/temp.linux-i686-2.5/numpy/linalg/lapack_litemodule.o
build/temp.linux-i686-2.5/numpy/linalg/python_xerbla.o
-L/share/astenv/devtools/compilers/ia32-unknown-linux_r3i11/intel/compiler111/mkl/lib/32
-L/share/astlib/temp/ia32-unknown-linux_r3i11/Python-2.5.1/lib
-Lbuild/temp.linux-i686-2.5 -L$MKLPATH $MKLPATH/libmkl_solver.a -Wl,--start-group -lmkl_intel -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp -lpthread -o build/lib.linux-i686-2.5/numpy/linalg/lapack_lite.so

----------------------------------------------------------------------

As the link-line-advisor suggested, we I did not explicitly link against '-lmkl_lapack', but if I add it to the link line, I get the same errors as before with mkl_def and mkl_p4m undefined symbols at runtime.

0 Kudos
Gennady_F_Intel
Moderator
558 Views
will replacing the-openmp by the -liomp5 help in this case?
0 Kudos
AndrewC
New Contributor III
558 Views
I am having the same problem as the OP when building a python module
MKL 10.2 Update 5, Intel 11.1 compilers, Linux 64-bit

When the python module loads at runtime I get

*** libmkl_mc.so *** failed with error :libmkl_mc.so: undefined symbol: mkl_dft_commit_descriptor_s_c2c_md_omp
*** libmkl_def.so *** failed with error : ibmkl_def.so: undefined symbol: mkl_dft_commit_descriptor_s_c2c_md_omp


The --startgroup and --endgroup did not help.

-L$(MKLROOT)/lib/em64t $(MKLROOT)/lib/em64t/libmkl_solver_lp64.a -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread
0 Kudos
TimP
Honored Contributor III
558 Views
will replacing the-openmp by the -liomp5 help in this case?

-openmp implicitly adds -liomp5. If using an integrated icc/mkl package, it should make no difference.
0 Kudos
Reply