使用英特尔编译器和MKL构建Numpy - CentOS 7

时间:2015-01-06 21:13:50

标签: python linux numpy intel-mkl centos7

目前我正在尝试使用CentOS 7上的英特尔编译器为英特尔MKL构建Numpy-1.9.1。我安装了Intel Parallel XE Studio 2015 C ++和Fortran for Linux,在我的终端中我可以同时使用'icc'和'ifort'命令,它们都没有问题。我也跑了:

$ source /opt/intel/composer_xe_2015/bin/compilervars.sh intel64

根据英特尔网页上的指南,我正在尝试做的事情:https://software.intel.com/en-us/articles/numpyscipy-with-intel-mkl,我尝试使用此命令构建numpy:

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

结果信息是:

Running from numpy source directory.
/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'test_suite'
  warnings.warn(msg)
non-existing path in 'numpy/f2py': 'docs'
non-existing path in 'numpy/f2py': 'f2py.1'
F2PY Version 2
blas_opt_info:
blas_mkl_info:
  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/intel/composer_xe_2015/mkl/lib/intel64']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/opt/intel/composer_xe_2015/mkl/include']

  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/intel/composer_xe_2015/mkl/lib/intel64']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/opt/intel/composer_xe_2015/mkl/include']

non-existing path in 'numpy/lib': 'benchmarks'
lapack_opt_info:
openblas_lapack_info:
  libraries openblas not found in ['/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
  NOT AVAILABLE

lapack_mkl_info:
mkl_info:
  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/intel/composer_xe_2015/mkl/lib/intel64']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/opt/intel/composer_xe_2015/mkl/include']

  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/intel/composer_xe_2015/mkl/lib/intel64']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/opt/intel/composer_xe_2015/mkl/include']

  FOUND:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/intel/composer_xe_2015/mkl/lib/intel64']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/opt/intel/composer_xe_2015/mkl/include']

/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'define_macros'
  warnings.warn(msg)
running config
running build_clib
running build_src
build_src
building py_modules sources
building library "npymath" sources
Could not locate executable icc
Could not locate executable ecc
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using config
C compiler: icc -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xhost

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/usr/include/python2.7 -c'
icc: _configtest.c
sh: icc: command not found
sh: icc: command not found
failure.
removing: _configtest.c _configtest.o
Traceback (most recent call last):
  File "setup.py", line 251, in <module>
    setup_package()
  File "setup.py", line 243, in setup_package
    setup(**metadata)
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/command/build_clib.py", line 63, in run
    self.run_command('build_src')
  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/command/build_src.py", line 153, in run
    self.build_sources()
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/command/build_src.py", line 164, in build_sources
    self.build_library_sources(*libname_info)
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/command/build_src.py", line 299, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/home/myles/Downloads/numpy-1.9.1/numpy/distutils/command/build_src.py", line 386, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 686, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program

我使用CentOS 7作为我的操作系统。看来由于某种原因,构建脚本找不到icc。

我需要使用英特尔编译器进行numpy构建,因为从我收集到的内容来看,我需要使用英特尔编译器和英特尔MKL进行numpy构建,以便自动卸载到Xeon Phi。如果有人为自动卸载到Xeon Phi构建了numpy,或者只是在这个问题上使用英特尔编译器构建了numpy,我将非常感谢修复此错误的输入。

1 个答案:

答案 0 :(得分:0)

在Unix / Linux系统上,sudo命令( S uper U ser DO )设置为使用为root用户定义的环境变量,而不是运行该命令的用户。如果您在非标准位置安装程序,则需要以超级用户权限运行该程序,这可能会导致问题。例如,在OS X系统上(运行在BSD Unix上),/usr/local/bin环境变量中默认不包含PATH。您可以设置用户的帐户以在PATH中包含此目录,但如果您尝试将sudo用于其中的程序,则无法找到该目录,除非您修改root要在/usr/local/bin中加入PATH的环境(或系统环境)。

这可能是您的问题的原因。 iccifort位于/opt/intel/bin和/或/opt/intel/composer_xe_2015/bin中的(IIRC)(其中一个可以与另一个进行符号链接),并且您已添加了至少一个您的$PATH环境变量的目录,但使用sudo执行构建命令时,找不到程序。要解决此问题,请不要使用sudo进行构建。首先,要清除任何剩余的临时文件,请运行

sudo make clean

然后运行

python setup.py config --compiler=intelem 

并确认所有设置正确。接下来,运行

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

构建一切。如果成功没有错误,可选择运行

python setup.py test

(我认为您不需要此目标的compiler参数)来验证构建,然后运行

sudo python setup.py install

在系统的site-packages目录中安装所有内容。此处需要sudo,因为site-packages拥有root