【问题标题】:Error: suffix or operands invalid for `vbroadcastss'错误:“vbroadcastss”的后缀或操作数无效
【发布时间】:2015-10-18 03:22:36
【问题描述】:

我正在尝试在 CentOS 6.5 服务器上通过 pip install annoy 安装 annoy,但出现以下错误。任何的想法?我在here 中找到了VBROADCASTSS,但仍然不知道如何修复这些错误。

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xxx/.pyenv/versions/2.7.10/include/python2.7 -c src/annoymodule.cc -o build/temp.linux-x86_64-2.7/src/annoymodule.o -O3 -march=native -ffast-math
cc1plus: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
In file included from /home/xxx/.pyenv/versions/2.7.10/include/python2.7/Python.h:8:0,
                 from src/annoymodule.cc:16:
/home/xxx/.pyenv/versions/2.7.10/include/python2.7/pyconfig.h:1188:0: warning: "_POSIX_C_SOURCE" redefined
 #define _POSIX_C_SOURCE 200112L
 ^
In file included from /usr/include/stdio.h:28:0,
                 from src/annoylib.h:18,
                 from src/annoymodule.cc:15:
/usr/include/features.h:162:0: note: this is the location of the previous definition
 # define _POSIX_C_SOURCE 200809L
 ^
In file included from /home/xxx/.pyenv/versions/2.7.10/include/python2.7/Python.h:8:0,
                 from src/annoymodule.cc:16:
/home/xxx/.pyenv/versions/2.7.10/include/python2.7/pyconfig.h:1210:0: warning: "_XOPEN_SOURCE" redefined
 #define _XOPEN_SOURCE 600
 ^
In file included from /usr/include/stdio.h:28:0,
                 from src/annoylib.h:18,
                 from src/annoymodule.cc:15:
/usr/include/features.h:164:0: note: this is the location of the previous definition
 # define _XOPEN_SOURCE 700
 ^

/tmp/ccfNu0mQ.s: Assembler messages:
/tmp/ccfNu0mQ.s:21160: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccfNu0mQ.s:21163: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccfNu0mQ.s:21532: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccfNu0mQ.s:24347: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccfNu0mQ.s:24350: Error: suffix or operands invalid for `vbroadcastss'
/tmp/ccfNu0mQ.s:24718: Error: suffix or operands invalid for `vbroadcastss'
error: command 'gcc' failed with exit status 1

【问题讨论】:

    标签: python compiler-errors avx avx2


    【解决方案1】:

    我使用gcc -march=native -Q --help=target 来比较几台 Linux 机器上的 gcc 设置。 我发现主要区别在于故障机器上的-march 行是haswell,其他的是 类似core...。以下是其他服务器的相应输出:

    CentOS release 6.5 (Final) - -march=corei7-avx

    CentOS Linux 7 (Core) - -march=core-avx-i

    Debian GNU/Linux 7 (wheezy) - -march=core-avx2

    我猜错误来自 gcc 使用的不同指令集。 在 annoy 的setup.py 中,-march=native 行中的extra_compile_args=['-O3', '-march=native', '-ffast-math'] 意味着 gcc 将尝试检测处理器并自动为其设置适当的标志。 所以我在setup.py中将此标志更改为-march=corei7-avx,错误就消失了。

    如果您有兴趣,请参阅here 中的-march 了解详情。

    更新

    在与服务器管理员确认后,此错误是由于 CentOS 加载程序软件比服务器中的新 Haswell CPU 更旧。安装最新版本的binutils 包也可以解决问题。

    【讨论】:

    • AVX 引入了vbroadcastss ymm, [m32],但是 AVX2 引入了vbroadcastss ymm, xmm 来广播源向量的低元素。大概使用-march=haswell, (avx2),代码生成了一些你的旧 binutils 无法组装的 asm。 (并且由于 vbroadcastss 的这种怪癖,你得到了“无效的操作数”而不是“无法识别的指令”。)
    • 你至少可以使用-mtune=haswell。但是生成较慢的代码来避免 AVX2 绕过旧工具链似乎是个坏主意。当然,使用较新的编译器和汇编器会更好,因为较新的编译器通常更擅长为新指令集自动矢量化,即它们可以从同一源生成更快/更好的代码。
    【解决方案2】:

    您的 binutils 版本太旧,无法支持 AVX/AVX2 指令,已检测到这些指令在您的处理器上可用。 您需要 binutils 2.22 或更高版本才能支持 AVX。

    【讨论】:

      猜你喜欢
      • 2016-03-31
      • 1970-01-01
      • 1970-01-01
      • 2011-07-26
      • 2018-08-15
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多