Community
cancel
Showing results for 
Search instead for 
Did you mean: 
250 Views

compiling and linking MKL with numpy/scipy

dear everyone,

I am hard trying to compile numpy / and scipy with mkl.

unfortunately it does not work. i have tried a lot of solution, and the closest for me to work is:

I have

Linux manning 2.6.32-27-server #49-Ubuntu SMP Thu Dec 2 02:05:21 UTC 2010 x86_64 GNU/Linux

python -c 'import os,sys;print os.name,sys.platform' ->posix linux

python 2.6

numpy 1.6.1

scipy 0.10

Intel Fortran Compiler XE Version 12.1 Update 1, Intel Debugger Version 12.1 Update 1, Intel Math Kernel Library (Intel MKL) Version 10.3 Update 7

I used this to help me: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/

the relevant part of site.cfg in numpy:

[mkl]
library_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/
include_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/include/
lapack_libs =
mmkl_libs = mkl_intel_ilp64 ,mkl_core ,mkl_intel_thread,mkl_mc

in distutils/intecompiler.py

cc_exe = 'icc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -DMKL_ILP64 '
ccxx_exe = 'icpc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -DMKL_ILP64 '

inin distutils/fcompiler/intel.py

def get_flags_opt(self):
return ['-O3 -openmp -i8 -fpe0 -L$(MKLROOT)/lib/intel64 -lpthread,']

I run in .bashrc

source /opt/intel/composer_xe_2011_sp1.7.256/bin/compilervars.sh intel64
source /opt/intel/composer_xe_2011_sp1.7.256/mkl/bin/mklvars.sh intel64 ilp64

and my complation script is:

export LD_LIBRARY_PATH=/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:$LD_LIBRARY_PATH

python setup.py config --compiler=intelem build_clib --compiler=intelem build_ext --compiler=intelem install

I had to use"-fp-model strict" to pass the simple test of numpy numpy.test()

but when I run numpy.test('full')

test_assumed_shape.TestAssumedShapeSumExample.test_all ... Segmentation fault

and then with the same config for scipy

scipy.test('full')

test_definition (test_basic.TestDoubleFFT) ... Segmentation fault

So what do I miss to make it work?

Thanks Xavier

0 Kudos
5 Replies
250 Views

Dear everyone

I have been a bit better

patching the files I finally get something

in .basrc

source /opt/intel/composer_xe_2011_sp1.7.256/bin/compilervars.sh intel64
source /opt/intel/composer_xe_2011_sp1.7.256/mkl/bin/mklvars.sh intel64 lp64
export OMP_NUM_THREADS=4
export KMP_AFFINITY=verbose,compact

env variables:
export LD_LIBRARY_PATH=/opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/:$LD_LIBRARY_PATH

site.cfg

[mkl]
library_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/
include_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/
lapack_libs =
mkl_libs = mkl_def, mkl_intel_lp64, mkl_core , mkl_intel_thread, mkl_mc

distutils/intelcompiler.py

cc_exe = 'icc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -lm'
ccxx_exe = 'icpc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -lm'


distutils/fcompiler/intel.py

return ['-O3 -openmp -fpe0 -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -lpthread -xHost -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include -lm']

in numpy.test("full")

i gettest_double (test_linalg.TestCond2) ... python: symbol lookup error: /opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/libmkl_sequential.so: undefined symbol: mkl_serv_lock

I am trying to look formkl_serv_lock, but impossible to find.

some ideas, someone?

Xavier

Ying_H_Intel
Employee
250 Views

Hi Xavier,

The smbols should be in libmkl_core.so.
nm libmkl_core.so | grep mkl_serv_lock
00000000000b2660 T mkl_serv_lock

It seems some thing is wrong in your mkl config and link.
could you check where the libmkl_sequential.so were loaded/linked?

Additionally, from the config
lapack_libs =
mkl_libs = mkl_def, mkl_intel_lp64, mkl_core , mkl_intel_thread, mkl_mc

The link order in linux is essential, soyou may change the order like
mkl_intel_lp64,
mkl_intel_thread
mkl_core

or use mkl_rt directly.

you mayrefer to the article : Numpy application notes http://software.intel.com/en-us/articles/numpy-user-note/

and http://software.intel.com/en-us/articles/a-new-linking-model-single-dynamic-library-mkl_rt-since-int...

Best Regards,
Ying
250 Views

It worked... amazing and terrifying at the same time. I didn't know order was important.

from the above I just change

mkl_libs = mkl_def, mkl_intel_lp64 , mkl_intel_thread, mkl_core, mkl_mc

and everything went fine!

thank you

Xavier

Ziyuan
Beginner
250 Views

Xavier Barthelemy wrote:

Dear everyone

I have been a bit better

patching the files I finally get something

in .basrc

source /opt/intel/composer_xe_2011_sp1.7.256/bin/compilervars.sh intel64
source /opt/intel/composer_xe_2011_sp1.7.256/mkl/bin/mklvars.sh intel64 lp64
export OMP_NUM_THREADS=4
export KMP_AFFINITY=verbose,compact

env variables:
export LD_LIBRARY_PATH=/opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/:$LD_LIBRARY_PATH

site.cfg

[mkl]
library_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/
include_dirs = /opt/intel/composer_xe_2011_sp1.7.256/mkl/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64/:/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/
lapack_libs =
mkl_libs = mkl_def, mkl_intel_lp64, mkl_core , mkl_intel_thread, mkl_mc

distutils/intelcompiler.py

cc_exe = 'icc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -lm'
ccxx_exe = 'icpc -m64 -O2 -fomit-frame-pointer -openmp -lpthread -fPIC -xHost -fp-model strict -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -lm'

distutils/fcompiler/intel.py

return ['-O3 -openmp -fpe0 -L/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64 -lpthread -xHost -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include/intel64/lp64 -I/opt/intel/composer_xe_2011_sp1.7.256/mkl/include -lm']

in numpy.test("full")

i gettest_double (test_linalg.TestCond2) ... python: symbol lookup error: /opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/libmkl_sequential.so: undefined symbol: mkl_serv_lock

I am trying to look formkl_serv_lock, but impossible to find.

some ideas, someone?

Xavier

 

 

How did you reach here? What is the main difference between #2 and #1 (looks like changing from ilp64 to lp64 but not sure)? Do you know how did the change affect the test? I have a very similar issue: http://stackoverflow.com/q/24777648/688080. Thank you.

Ying_H_Intel
Employee
250 Views

Hi Ziyuan, 

Could you please try -O1 option for Intel fortran compiler. We have issue with ifort in latest composer version. 

https://software.intel.com/en-us/forums/topic/505993

Best Regards,

Ying 

Reply