Numpy building error: gcc: build/src.linux-x86_64-3.10/numpy/core/src/umath/loops.c

Issue

I’m trying to install Numpy v1.22.4 via pip, next via compiling source code.
I encountered below error when I executed $ 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

Below is the things I tried:

  • Installing Python 3.10.4 on CentOS 6.
    *Because it seems that Python 3.10.3 cannot be run on CentOS 6.
  • Installing gcc v9.5.0, plus v11.3.0.
    *Separately from default gcc (v4.4.7).
    *I used contrib/download_prerequisites when I installed gcc v11.3.0.
  • Updating libstdc++ from gcc v11.3.0.

*I describe more details later.

Could you please tell me how to solve this error?

My development environment information

(.venv) [[email protected] ~]$ cat /etc/redhat-release 
CentOS release 6.10 (Final)

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

(.venv) [[email protected] ~]$ which pip
/var/www/project/my-product/.venv/bin/pip
(.venv) [[email protected] ~]$ pip -V
pip 22.1.1 from /var/www/project/my-product/.venv/lib/python3.10/site-packages/pip (python 3.10)
(.venv) [[email protected] ~]$ 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) [[email protected] ~]$ python -m cython --version
Cython version 0.29.30

(.venv) [[email protected] ~]$ which gcc
/usr/local/bin/gcc
(.venv) [[email protected] ~]$ 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) [[email protected] ~]$ which g++
/usr/local/bin/g++
(.venv) [[email protected] ~]$ 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) [[email protected] ~]$ 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) [[email protected] ~]$ 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  

Commands I executed

(.venv) [[email protected] src]$ pwd
/home/vagrant/src
(.venv) [[email protected] src]$ git clone https://github.com/numpy/numpy.git
(.venv) [[email protected] src]$ cd numpy
(.venv) [[email protected] numpy]$ git checkout refs/tags/v1.22.4
(.venv) [[email protected] numpy]$ git submodule update --init
(.venv) [[email protected] 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

Solution

It seems that I need at least gcc 11.2, for -O3, then I upgraded GNU assembler through Binutils 2.38 package.
I could solve my problem by the upgrading.

Answered By – Mocchaso

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published