gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 03:47:06 25 4
gpt4 key购买 nike

目前,我正在尝试使用 CentOS 7 上的英特尔编译器为英特尔的 MKL 构建 Numpy-1.9.1。我安装了适用于 Linux 的英特尔 Parallel XE Studio 2015 C++ 和 Fortran,在我的终端中我可以使用“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 可用。如果有人构建了 numpy 来自动卸载到 Xeon Phi,或者只是使用英特尔编译器构建了 numpy,我将非常感谢您提供修复此错误的信息。

最佳答案

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

这可能是导致您出现问题的原因。 iccifort 位于 /opt/intel/bin 和/或 /opt/intel/composer_xe_2015/bin 中的 (IIRC)(其中一个可能符号链接(symbolic link)到另一个),并且您已将这些目录中的至少一个添加到 $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

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

sudo python setup.py install

安装系统的 site-packages 目录中的所有内容。这里需要 sudo,因为 site-packagesroot 所有。

关于python - 使用英特尔编译器和 MKL 构建 Numpy - CentOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27807272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com