【问题标题】:Numpy building error: gcc: build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.cNumpy 构建错误:gcc: build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.c
【发布时间】:2022-07-08 08:03:21
【问题描述】:

我正在尝试通过pip 安装 Numpy v1.22.4,接下来通过编译源代码。
执行$ python setup.py build时遇到以下错误。

error: Command "gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -DNO_ATLAS_INFO=-1 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/core/include/numpy -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/var/www/project/my-product/.venv/include -I/usr/local/include/python3.10 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/npymath -c build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.c -o build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.o -MMD -MF build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.o.d -msse -msse2 -msse3" failed with exit status 1

以下是我尝试过的事情:

  • 在 CentOS 6 上安装 Python 3.10.4。
    *因为似乎 Python 3.10.3 无法在 CentOS 6 上运行。
  • 正在安装 gcc v9.5.0,以及 v11.3.0。
    *与默认 gcc (v4.4.7) 分开。
    *我在安装 gcc v11.3.0 时使用了contrib/download_prerequisites
  • 从 gcc v11.3.0 更新 libstdc++。

*我稍后会描述更多细节。

您能告诉我如何解决这个错误吗?

我的开发环境资料

(.venv) [vagrant@localhost ~]$ cat /etc/redhat-release 
CentOS release 6.10 (Final)

(.venv) [vagrant@localhost ~]$ which python
/var/www/project/my-product/.venv/bin/python
(.venv) [vagrant@localhost ~]$ python -V
Python 3.10.4

(.venv) [vagrant@localhost ~]$ which pip
/var/www/project/my-product/.venv/bin/pip
(.venv) [vagrant@localhost ~]$ pip -V
pip 22.1.1 from /var/www/project/my-product/.venv/lib/python3.10/site-packages/pip (python 3.10)
(.venv) [vagrant@localhost ~]$ pip list
Package    Version
---------- -------
Cython     0.29.30
pip        22.1.1
setuptools 62.3.2
WARNING: There was an error checking the latest version of pip.
(.venv) [vagrant@localhost ~]$ python -m cython --version
Cython version 0.29.30

(.venv) [vagrant@localhost ~]$ which gcc
/usr/local/bin/gcc
(.venv) [vagrant@localhost ~]$ gcc --version
gcc (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(.venv) [vagrant@localhost ~]$ which g++
/usr/local/bin/g++
(.venv) [vagrant@localhost ~]$ g++ --version
g++ (GCC) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(.venv) [vagrant@localhost ~]$ strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

(.venv) [vagrant@localhost ~]$ sudo yum list installed | grep -e "atlas" -e "lapack" -e "blas" -e "gfortran" -e "gmp" -e "mpfr" -e "mpc" -e "python-devel" -e "python34-devel" -e "Cython"
atlas.x86_64                        3.8.4-2.el6                      @base      
atlas-devel.x86_64                  3.8.4-2.el6                      @base      
blas.x86_64                         3.2.1-5.el6                      @base      
blas-devel.x86_64                   3.2.1-5.el6                      @base      
gcc-gfortran.x86_64                 4.4.7-23.el6                     @base      
gmp.x86_64                          4.3.1-13.el6                     @base      
gmp-devel.x86_64                    4.3.1-13.el6                     @base      
lapack.x86_64                       3.2.1-5.el6                      @base      
lapack-devel.x86_64                 3.2.1-5.el6                      @base      
libgfortran.x86_64                  4.4.7-23.el6                     @base      
libmpc.x86_64                       0.8-3.el6                        @epel      
libmpc-devel.x86_64                 0.8-3.el6                        @epel      
mpfr.x86_64                         2.4.1-6.el6                      @base      
mpfr-devel.x86_64                   2.4.1-6.el6                      @base      
openblas.x86_64                     0.3.3-2.el6                      @epel      
python-devel.x86_64                 2.6.6-68.el6_10                  @updates   
python34-devel.x86_64               3.4.10-4.el6                     @epel  

我执行的命令

(.venv) [vagrant@localhost src]$ pwd
/home/vagrant/src
(.venv) [vagrant@localhost src]$ git clone https://github.com/numpy/numpy.git
(.venv) [vagrant@localhost src]$ cd numpy
(.venv) [vagrant@localhost numpy]$ git checkout refs/tags/v1.22.4
(.venv) [vagrant@localhost numpy]$ git submodule update --init
(.venv) [vagrant@localhost numpy]$ python setup.py build 2>&1 | tee build_log.txt

... *Omitting

INFO: compile options: '-DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -DNO_ATLAS_INFO=-1 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/core/include/numpy -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/var/www/project/my-product/.venv/include -I/usr/local/include/python3.10 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/npymath -c'
extra options: '-O3 -msse -msse2 -msse3'
INFO: compiling C sources
INFO: C compiler: gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC

INFO: compile options: '-DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -DNO_ATLAS_INFO=-1 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/core/include/numpy -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/var/www/project/my-product/.venv/include -I/usr/local/include/python3.10 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/npymath -c'
extra options: '-msse -msse2 -msse3'
INFO: gcc: build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.c
/tmp/ccuh177O.s: Assembler messages:
/tmp/ccuh177O.s:36: Error: no such instruction: `vpbroadcastd %edx,%zmm1'
/tmp/ccuh177O.s:37: Error: bad register name `%zmm1'
/tmp/ccuh177O.s:63: Error: bad register name `%zmm2'
/tmp/ccuh177O.s:69: Error: no such instruction: `kxnorw %k1,%k1,%k1'

... *Omitting

/tmp/ccuh177O.s:18728: Error: no such instruction: `kmovw %ecx,%k1'
/tmp/ccuh177O.s:18741: Error: invalid character '{' in operand 2
/tmp/ccuh177O.s:18754: Error: invalid character '{' in operand 2
/tmp/ccuh177O.s:18777: Error: bad register name `%zmm1'
/tmp/ccuh177O.s:18792: Error: bad register name `%zmm0'
/tmp/ccuh177O.s:18801: Error: bad register name `%zmm1'
/tmp/ccuh177O.s:18810: Error: bad register name `%zmm0'
error: Command "gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DHAVE_CBLAS -DNO_ATLAS_INFO=-1 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/core/include/numpy -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/var/www/project/my-product/.venv/include -I/usr/local/include/python3.10 -Ibuild/src.linux-x86_64-3.10/numpy/core/src/common -Ibuild/src.linux-x86_64-3.10/numpy/core/src/npymath -c build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.c -o build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.o -MMD -MF build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.o.d -msse -msse2 -msse3" failed with exit status 1
INFO: 
########### EXT COMPILER OPTIMIZATION ###########
INFO: Platform      : 
  Architecture: x64
  Compiler    : gcc

CPU baseline  : 
  Requested   : 'min'
  Enabled     : SSE SSE2 SSE3
  Flags       : -msse -msse2 -msse3
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3
  Generated   : 
              : 
  SSE41       : SSE SSE2 SSE3 SSSE3
  Flags       : -msse -msse2 -msse3 -mssse3 -msse4.1
  Extra checks: none
  Detect      : SSE SSE2 SSE3 SSSE3 SSE41
              : build/src.linux-x86_64-3.10/numpy/core/src/umath/loops_arithmetic.dispatch.c
              : build/src.linux-x86_64-3.10/numpy/core/src/umath/loops_unary_fp.dispatch.c
INFO: CCompilerOpt.cache_flush[825] : write cache to path -> /home/vagrant/src/numpy/build/temp.linux-x86_64-cpython-310/ccompiler_opt_cache_ext.py
INFO: 
########### CLIB COMPILER OPTIMIZATION ###########
INFO: Platform      : 
  Architecture: x64
  Compiler    : gcc

CPU baseline  : 
  Requested   : 'min'
  Enabled     : SSE SSE2 SSE3
  Flags       : -msse -msse2 -msse3
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3
  Generated   : none
INFO: CCompilerOpt.cache_flush[825] : write cache to path -> /home/vagrant/src/numpy/build/temp.linux-x86_64-cpython-310/ccompiler_opt_cache_clib.py

【问题讨论】:

  • 当您只请求 SSE(>15 岁)时,您似乎遇到了一些与 AVX-512 相关的问题。如果您在最新的 Intel 处理器(例如 IceLake/CannonLake 或 Skylake SP)上运行,那么启用 AVX-512 怎么样?顺便说一句,请检查 GCC 的默认版本是不是 4.4.7(很旧)。另外,您的确切目标平台是什么?
  • 感谢您的帮助。我的开发环境的处理器是 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz。 (我通过/proc/cpuinfo查看)默认gcc版本是4.4.7...如何确认目标平台...?
  • 好的,所以您的处理器不支持 AVX-512(但它支持 AVX-2,因此最好使用 -mavx2 编译标志添加它)。这意味着某些东西是在 AVX-512 的支持下构建的,然后 GCC 汇编器会抱怨,因为它是意外的(编译器生成了 AVX-512 汇编指令)。假设问题不是来自 Numpy(现在 1.22.4 应该很稳定),可能是由于使用 AVX-512 编译的依赖库(例如 glibc、libm 等),一些坏的旧文件编译为AVX-512 仍在缓存中,等等。很难说更多。
  • 好的,非常感谢!我会特别研究与 AVX512 相关的内容。

标签: python c++ c linux numpy


【解决方案1】:

看来I need at least gcc 11.2,对于-O3,然后我通过Binutils 2.38包升级了GNU汇编器。 我可以通过升级解决我的问题。

【讨论】:

    猜你喜欢
    • 2011-08-12
    • 2021-11-30
    • 2015-06-01
    • 1970-01-01
    • 2022-06-30
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    相关资源
    最近更新 更多