flash-attn安装卡在Building wheel for flash-attn (setup.py)
问题
pip install flash-attn
pip install flash-attn --no-build-isolation
都卡在uilding wheel for flash-attn (setup.py)这一步不动了。
解决方法
直接下载 GitHub Release 中的预编译 wheel: Dao-AILab/flash-attention
- 查看自己的版本
python -c "import torch; print(torch.__version__)"
nvcc --version
例如输出为
torch.__version__ = 2.9.0+cu128
nvcc --version → CUDA 12.2
那么可以知道自己当下的版本是torch2.9 + cuda12.2
- 从release里找合适自己的预编译 wheel
我选择的是:flash_attn-2.8.3+cu12torch2.8cxx11abiFALSE-cp310-cp310-linux_x86_64.whl,从命名可以看出:
- flash-attn2.8.3
- cuda12 - 适配cuda12.2
- torch2.8 - 因为使用的torch2.9是2.8的light,可以直接用2.8
- cxx11abiFalse(一般都得用false,具体原因太长忘了)
- cp310 - 适配python3.10
- 最后下载好whl进行安装,完成
pip install flash_attn-2.8.3+cu12torch2.8cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
