尝试使用 python pip 安装 SIMD CPU 优化的 numpy

Trying to install numpy with SIMD CPU Optimizations using python pip

提问人:Alex Radwan 提问时间:11/6/2023 更新时间:11/6/2023 访问量:35

问:

我正在尝试通过 pip 使用 CPU 优化安装 numpy,但我不确定我是否正确安装了优化。

根据这里的文档,我正在运行这个

pip install --no-cache-dir --global-option=build --global-option="--cpu-baseline=sse3" --global-option="--cpu-dispatch=max -ssse3 -sse41 -popcnt -sse42 -avx -xop -fma4 -f16c -fma3 -avx2 -avx512f -avx512cd -avx512_knl -avx512_knm -avx512_skx -avx512_clx -avx512_cnl -avx512_icl -avx512_spr" numpy

这给了我输出:

DEPRECATION: --build-option and --global-option are deprecated. pip 24.0 will enforce this behaviour change. A possible replacement is to use --config-settings. Discussion can be found at https://github.com/pypa/pip/issues/11859
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option. 
Collecting numpy
  Downloading numpy-1.26.1.tar.gz (15.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 55.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: numpy
  WARNING: Ignoring --global-option when building numpy using PEP 517
  Building wheel for numpy (pyproject.toml) ... done
  Created wheel for numpy: filename=numpy-1.26.1-cp311-cp311-linux_x86_64.whl size=26811457 sha256=a57a2dd0a4f297f75ce0f0110601e4e69aa8da60e8e3e967ad1aa7ed3a383fff
  Stored in directory: /tmp/pip-ephem-wheel-cache-3xaj9yt4/wheels/2a/39/b4/338b7162547e7d40b5f8db8d71f5c136f32ce4b00b5e078185
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-1.26.1

现在,我不确定 CPU 优化是否因为这条线而启动WARNING: Ignoring --global-option when building numpy using PEP 517

我尝试安装,但这导致了错误--no-use-pep517 ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of mesonpy in pyproject.toml

所以即使使用此选项使用源代码,我也无法构建,因为 numpy 使用 mesonpy 来构建,我该如何解决这个问题?

python numpy pip 构建 simd

评论

3赞 Jérôme Richard 11/6/2023
您可能会在 Numpy 的 Github 上获得有关问题帖子的更多帮助(特别是如果这是一个错误——文档中提供的确切命令必须有效)。
0赞 Peter Cordes 11/6/2023
我很确定没有同时支持 AMD XOP(在 Zen 1 及更高版本中删除)和 AVX-512 的 CPU。(AMD 的 Zen 4 中的新功能)。如果这些是单独的动态调度可能性,那么当然可以,但启用 XOP 不是很有用,因为只有过时的 AMD Bulldozer 系列 CPU 才有它。

答: 暂无答案