Skip to content
Discussion options

You must be logged in to vote

同样遇到该问题,这里分享一下 Ubuntu 上手动编译无任何编译器优化版本的 Numpy 过程。

环境信息

  • NumPy 版本:2.4.0
  • 操作系统:Ubuntu Server 24.04

步骤 1:安装编译依赖

sudo apt build-dep numpy

步骤 2:克隆仓库并切换到目标版本

git clone https://github.com/numpy/numpy.git && cd numpy
git checkout v2.4.0

步骤 3:编译(禁用所有指令集优化)

通过 -Dcpu-baseline="none" 和 -Dcpu-dispatch="none" 参数,确保编译产物不依赖任何特定指令集:

python -m build --wheel \
    -Csetup-args=-Dcpu-baseline="none" -Csetup-args=-Dcpu-dispatch="none"

步骤 4:安装编译产物

编译完成后,wheel 文件位于 dist/ 目录下,使用 --force-reinstall 覆盖原有安装:

pip install /path/to/numpy/dist/numpy-2.4.0-cp312-cp312-linux_x86_64.whl --force-reinstall

至此,问题解决。

Warning

通过这种方式安装 Numpy 以后,一定要使用 uv run --no-sync 运行项目。

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by anka-afk
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
4 participants
Converted from issue

This discussion was converted from issue #4169 on October 15, 2026 09:11.