bpartridge / PyPhi

Python for Scientific Computing on Intel's Xeon Phi MIC Platform
22 stars 7 forks source link

compile error for numpy #2

Open baugp opened 10 years ago

baugp commented 10 years ago

Thank you very much for this package. The cross-compilation of python works however we get an error for the numpy package. We would be very grateful if you could give us directions to solve this.

In the Makefile:

numpyxc: numpy | $(MIC_PY_HOME) $(NP_UTILS)
    build_clib forces config.h to be created; it needs to be modified before extensions are built
    cd numpy && PYTHONXCPREFIX=$(MIC_PY_HOME) python numpyxc.py build_clib
    sed '/INTRIN/ d' -i numpy/build/*/numpy/core/include/numpy/config.h
**FAILS:  cd numpy && PYTHONXCPREFIX=$(MIC_PY_HOME) python numpyxc.py build**
    cd numpy && PYTHONXCPREFIX=$(MIC_PY_HOME) python numpyxc.py install --prefix=$(MIC_PY_HOME)

Error Message:

compile options: '-DHAVE_NPY_CONFIG_H=1 -Inumpy/core/include -Ibuild/src.linux-x86_64-2.6/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/usr/include/python2.6 -c'
icc: numpy/core/src/dummymodule.c
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
icc -mmic -mkl -fPIC -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib -shared build/temp.linux-x86_64-2.6/numpy/core/src/dummymodule.o -L/usr/lib64 -Lbuild/temp.linux-x86_64-2.6 -lpython2.6 -o build/lib.linux-x86_64-2.6/numpy/core/_dummy.so
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpython2.6.so when searching for -lpython2.6
x86_64-k1om-linux-ld: cannot find -lpython2.6
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libm.so when searching for -lm
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpthread.so when searching for -lpthread
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpython2.6.so when searching for -lpython2.6
x86_64-k1om-linux-ld: cannot find -lpython2.6
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libm.so when searching for -lm
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpthread.so when searching for -lpthread
error: Command "icc -mmic -mkl -fPIC -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib -shared build/temp.linux-x86_64-2.6/numpy/core/src/dummymodule.o -L/usr/lib64 -Lbuild/temp.linux-x86_64-2.6 -lpython2.6 -o build/lib.linux-x86_64-2.6/numpy/core/_dummy.so" failed with exit status 1
make: *** [numpyxc] Error 1
bpartridge commented 10 years ago

Thanks for letting me know! It seems that it's trying to link to the python2.6 library, but what we're cross-compiling is python2.7 (2.7.3, specifically).

Here's the corresponding lines in my build:

compile options: '-DHAVE_NPY_CONFIG_H=1 -Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/global/homes/b/bpartrid/anaconda/include/python2.7 -c'
icc: numpy/core/src/dummymodule.c
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
icc -mmic -mkl -fPIC -fp-model strict -g -I/chos/global/u1/b/bpartrid/mic3/python/_install/include -L/chos/global/u1/b/bpartrid/mic3/python/_install/lib -L/chos/global/u1/b/bpartrid/mic3/python/_install/lib/python2.7 -L/chos/global/u1/b/bpartrid/mic3/python/_install/lib/python2.7/site-packages/numpy/core/lib -shared build/temp.linux-x86_64-2.7/numpy/core/src/dummymodule.o -L/global/homes/b/bpartrid/anaconda/lib -Lbuild/temp.linux-x86_64-2.7 -lpython2.7 -o build/lib.linux-x86_64-2.7/numpy/core/_dummy.so

My best guess is that you have Python 2.6 installed on your system natively, not Python 2.7, which I had on all my test platforms (via Anaconda, but that shouldn't be necessary). Can you try running python -V on your compile platform (not the MIC card) and showing what you get?

I've done my best to make Numpy's build process not assume anything about what's already installed on your system, but it's possible that somewhere in there, it's using whatever python process is on your $PATH for some sort of feature detection instead of the hostpython we compiled from scratch, and if that python is Python 2.6, then it will cause Numpy to look for python2.6 libraries... and we haven't compiled any 2.6 libraries for MIC, only 2.7!

You might be able to fix it by upgrading your native python to the latest 2.7. Otherwise, I can try to drill down and make sure that Numpy is using the non-MIC 2.7.3 hostpython we compiled, which would be the preferable long-term solution, but it may be difficult if Numpy has hard-coded assumptions that you'd always be using a process named python on the $PATH to compile it.

baugp commented 10 years ago

Thank you, you were right. I did not change my environment variables to point to python27. However, I have another problem; I would assume I need the BLAS (openblas) libaries compiled for the XeonPhi? - Do you have any suggestions?

unable to execute _configtest: Exec format error
failure.
removing: _configtest.c _configtest.o _configtest
building data_files sources
build_src: building npy-pkg config files
running build_py
copying numpy/version.py -> build/lib.linux-x86_64-2.7/numpy
copying build/src.linux-x86_64-2.7/numpy/__config__.py -> build/lib.linux-x86_64-2.7/numpy
copying build/src.linux-x86_64-2.7/numpy/distutils/__config__.py -> build/lib.linux-x86_64-2.7/numpy/distutils
running build_clib
customize IntelMICCompiler
customize IntelMICCompiler using build_clib
running build_ext
customize IntelMICCompiler
customize IntelMICCompiler using build_ext
customize IntelMICFCompiler
customize IntelMICFCompiler using build_ext
building 'numpy.linalg.lapack_lite' extension
compiling C sources
C compiler: icc -mmic -mkl -fPIC -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib

compile options: '-Inumpy/core/include -Ibuild/src.linux-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/opt/rh/python27/root/usr/include/python2.7 -c'
icc: numpy/linalg/lapack_litemodule.c
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
icc: numpy/linalg/lapack_lite/python_xerbla.c
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -shared -fPIC -shared -mmic -mkl -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib build/temp.linux-x86_64-2.7/numpy/linalg/lapack_litemodule.o build/temp.linux-x86_64-2.7/numpy/linalg/lapack_lite/python_xerbla.o -L/usr/lib64 -L/opt/rh/python27/root/usr/lib64 -Lbuild/temp.linux-x86_64-2.7 -lopenblas -lpython2.7 -o build/lib.linux-x86_64-2.7/numpy/linalg/lapack_lite.so
ifort: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libopenblas.so when searching for -lopenblas
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libopenblas.a when searching for -lopenblas
x86_64-k1om-linux-ld: cannot find -lopenblas
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libm.so when searching for -lm
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpthread.so when searching for -lpthread
ifort: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libopenblas.so when searching for -lopenblas
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libopenblas.a when searching for -lopenblas
x86_64-k1om-linux-ld: cannot find -lopenblas
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libm.so when searching for -lm
x86_64-k1om-linux-ld: skipping incompatible /usr/lib64/libpthread.so when searching for -lpthread
error: Command "/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -shared -fPIC -shared -mmic -mkl -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib build/temp.linux-x86_64-2.7/numpy/linalg/lapack_litemodule.o build/temp.linux-x86_64-2.7/numpy/linalg/lapack_lite/python_xerbla.o -L/usr/lib64 -L/opt/rh/python27/root/usr/lib64 -Lbuild/temp.linux-x86_64-2.7 -lopenblas -lpython2.7 -o build/lib.linux-x86_64-2.7/numpy/linalg/lapack_lite.so" failed with exit status 1
make: *** [numpyxc] Error 1
bpartridge commented 10 years ago

Intel should have openblas already compiled for the Phi in /opt/intel/composer_xe_2013_sp1/mkl/lib/mic. My understanding is that even if you're using a different version of sp1, it should be symlinked there. It that's not the case and you're using different paths, you'll need to edit site.cfg in your Numpy directory to point to the correct composer directory; this is downloaded by our makefile in make numpyutils. I recommend running make numpyclean, editing the config file, then running make numpyxc.

baugp commented 10 years ago

Thank you. Turns out when uninstalling openblas on the host this error doesn't appear. However I get now a problem with scipyxc. It looks similar to the error above, but this time with libnpymath:

icc: build/src.linux-x86_64-2.7/scipy/special/_logit.c
icc: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -shared -fPIC -shared -mmic -mkl -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib build/temp.linux-x86_64-2.7/scipy/special/_ufuncs.o build/temp.linux-x86_64-2.7/scipy/special/sf_error.o build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scipy/special/_logit.o build/temp.linux-x86_64-2.7/scipy/special/amos_wrappers.o build/temp.linux-x86_64-2.7/scipy/special/cdf_wrappers.o build/temp.linux-x86_64-2.7/scipy/special/specfun_wrappers.o -L/opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy-1.8.1-py2.7-linux-x86_64.egg/numpy/core/lib -L/opt/rh/python27/root/usr/lib64 -Lbuild/temp.linux-x86_64-2.7 -lsc_amos -lsc_c_misc -lsc_cephes -lsc_mach -lsc_cdf -lsc_specfun -lnpymath -lm -lpython2.7 -o build/lib.linux-x86_64-2.7/scipy/special/_ufuncs.so
ifort: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy-1.8.1-py2.7-linux-x86_64.egg/numpy/core/lib/libnpymath.a when searching for -lnpymath
x86_64-k1om-linux-ld: cannot find -lnpymath
ifort: command line remark #10364: Using '-fp-model strict' forces the compiler to generate legacy floating-point instructions instead of KNC for most floating-point operations, which may impact performance.  Consider using a floating-point model that allows the compiler to assume the default floating-point environment. 
x86_64-k1om-linux-ld: skipping incompatible /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy-1.8.1-py2.7-linux-x86_64.egg/numpy/core/lib/libnpymath.a when searching for -lnpymath
x86_64-k1om-linux-ld: cannot find -lnpymath
error: Command "/opt/intel/composer_xe_2013_sp1.1.106/bin/intel64/ifort -shared -fPIC -shared -mmic -mkl -fp-model strict -g -I/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/include -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7 -L/home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib build/temp.linux-x86_64-2.7/scipy/special/_ufuncs.o build/temp.linux-x86_64-2.7/scipy/special/sf_error.o build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/scipy/special/_logit.o build/temp.linux-x86_64-2.7/scipy/special/amos_wrappers.o build/temp.linux-x86_64-2.7/scipy/special/cdf_wrappers.o build/temp.linux-x86_64-2.7/scipy/special/specfun_wrappers.o -L/opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy-1.8.1-py2.7-linux-x86_64.egg/numpy/core/lib -L/opt/rh/python27/root/usr/lib64 -Lbuild/temp.linux-x86_64-2.7 -lsc_amos -lsc_c_misc -lsc_cephes -lsc_mach -lsc_cdf -lsc_specfun -lnpymath -lm -lpython2.7 -o build/lib.linux-x86_64-2.7/scipy/special/_ufuncs.so" failed with exit status 1
make: *** [scipyxc] Error 1
bpartridge commented 10 years ago

I'll need to look at this tomorrow, but when I compile I don't see it touching _logit.c for some reason. However can you see a libnpymath in your /home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib/python2.7/site-packages/numpy/core/lib?

baugp commented 10 years ago

The libnpymath libary was in: /home/kml112/Downloads/PYTHON_MIC/PyPhi-master/python/_install/lib64/python2.7/site-packages/numpy/core/lib (not */_install/lib/* but in */_install/lib64/*)

I tried to include that */_install/lib64/*/numpy/core/lib dir into the lib search path but that didn't quite work, so I just temporarily symlinked the libnpymath (MIC-architecture) into the hosts search path /opt/rh/python27/root/usr/lib/python2.7/site-packages/numpy-1.8.1-py2.7-linux-x86_64.egg/numpy/core/lib/ which worked.

Thank you very much, I was able to get both libaries to work on theMIC