使用python3.3在OSX上用MKL构建NumPy时出错

2024-06-25 22:52:31 发布

您现在位置:Python中文网/ 问答频道 /正文

背景

使用带有第二代酷睿i7处理器的2012年iMac,我试图在OSX 10.8.3上构建NumPy1.7.0(最终是SciPY),该版本链接到英特尔的C++ Composer XE 2013Fortran Composer XE 2013的评估版中。我在英特尔的站点上关注this article的设置、编译器标志等

问题

使用以下任一选项:

$ python3 setup.py config build --compiler=intelem --fcompiler=intelem

或者

^{pr2}$

我也有同样的错误:

running build_clib
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_clib
running build_ext
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_ext
building 'numpy.core._dummy' extension
compiling C sources
C compiler: icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include

compile options: '-Inumpy/core/include -Ibuild/src.macosx-10.8-x86_64-3.3/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/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/src/multiarray -Ibuild/src.macosx-10.8-x86_64-3.3/numpy/core/src/umath -c'
icc: numpy/core/src/dummymodule.c
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include -shared build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc: command line warning #10006: ignoring unknown option '-shared'
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
icc: command line warning #10121: overriding '-marchcorei7' with '-xhost'
icc: command line warning #10006: ignoring unknown option '-shared'
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
error: Command "icc -m64 -march=corei7 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -I/opt/intel/mkl/include -shared build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so" failed with exit status 1

我的LD_LIBRARY_PATH和{}都是:

/opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib

我的DYLD_FRAMEWORK_PATH是:

/opt/local/Library/Frameworks:/Library/Frameworks:/System/Library/Frameworks

我的site.cfg是:

[DEFAULT]
library_dirs = /opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib
include_dirs = /opt/intel/include:/opt/intel/include/intel64:/opt/intel/mkl/include:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m:/opt/local/include:/usr/local/include:/usr/include

[mkl]
library_dirs = /opt/intel/lib/intel64:/opt/intel/lib:/opt/intel/mkl/lib:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib:/opt/local/lib:/usr/local/lib:/usr/lib
include_dirs = /opt/intel/include:/opt/intel/include/intel64:/opt/intel/mkl/include:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m:/opt/local/include:/usr/local/include:/usr/include
mkl_libs = mkl_rt
lapack_libs = mkl_lapack

指向iccifort的符号链接位于/usr/bin中,并且是功能性的。dummymodule.c的内容可在GitHub上的numpy存储库中找到。我不是一个C程序员,所以我不能马上看出问题所在。我在使用MacPortsPython3.3.0(使用上述设置)和python.org网站3.3.0,修改了指向它而不是/opt/local的设置。在

抗辩

有人能帮忙弄清楚吗?在

编辑

我把-shared换成了-dynamiclib,现在得到了:

building extension "numpy.random.mtrand" sources
C compiler: icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64

compile options: '-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/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c'
icc: _configtest.c
icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 _configtest.o -o _configtest
_configtest
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.macosx-10.8-x86_64-3.3/numpy
copying build/src.macosx-10.8-x86_64-3.3/numpy/__config__.py -> build/lib.macosx-10.8-x86_64-3.3/numpy
copying numpy/distutils/intelccompiler.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils
copying build/src.macosx-10.8-x86_64-3.3/numpy/distutils/__config__.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils
copying numpy/distutils/fcompiler/intel.py -> build/lib.macosx-10.8-x86_64-3.3/numpy/distutils/fcompiler
running build_clib
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_clib
running build_ext
customize IntelEM64TCCompiler
customize IntelEM64TCCompiler using build_ext
building 'numpy.core._dummy' extension
compiling C sources
C compiler: icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64

compile options: '-Inumpy/core/include -Ibuild/src.macosx-10.8-x86_64-3.3/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/local/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -c'
icc: numpy/core/src/dummymodule.c
icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64
Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64
error: Command "icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so" failed with exit status 1

因此,我在configtest(不确定这是关于什么的)之后得到一行内容是failure.,下面是相同的错误。思想?在


Tags: corebuildsrcnumpyincludeliblocalx86
2条回答

icc: command line warning #10006: ignoring unknown option '-shared'

有个问题。您的编译器正在尝试生成一个可执行文件,即使它被告知要构建一个共享库。根据icc文档,-shared仅在Linux系统上可用。因为您的系统是MacOSX系统,所以我想您应该使用-dynamiclib。在

编辑:我怀疑您丢失了一个指向pylib的链接:icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost -DMKL_ILP64 -dynamiclib build/temp.macosx-10.8-x86_64-3.3/numpy/core/src/dummymodule.o -Lbuild/temp.macosx-10.8-x86_64-3.3 -o build/lib.macosx-10.8-x86_64-3.3/numpy/core/_dummy.so。在

缺少链接会导致以下情况:

Undefined symbols for architecture x86_64:
  "_PyModule_Create2", referenced from:
      _PyInit__dummy in dummymodule.o
ld: symbol(s) not found for architecture x86_64

您需要添加-lpythonX.Y,其中X.Y表示链接所针对的Python版本。如果该文件存在,但链接器找不到它,则需要使用-Llink/search/directory(例如-Llib/)指令告诉链接器它在哪里。如果文件不存在,您需要构建它。在

我建议您更改文件numpy-1.7.0/numpy/distutils/intelccompiler.py第37行至

icc-m64-fPIC-O3-g-fPIC-fp model strict-fomit帧指针-openmp-xhost-undefined dynamic_查找-bundle-DMKL'ILP64

我以前有过这个编译错误

相关问题 更多 >