报错信息
ImportError: /home/operationgpt/anaconda3/envs/lyj_py10_torch230/lib/python3.10/site-packages/flash_attn_2_cuda.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZN3c104cuda9SetDeviceEi
解决方式:重装 Flash Attention
- 卸载已有的 flash-attn,输入
pip uninstall flash-attn,然后输入 y。 - 查看自己对应的 torch 版本、cuda 版本和 python 版本。
查看 torch 版本
pip show torch
返回结果中可知 torch 版本为 2.3.1。
查看 cuda 版本
nvcc -V
cuda 版本为 V12.5.40。
查看 python 版本
python --version
- 前往 Flash Attention 官网下载安装包,注意需要根据自己的 torch 版本、cuda 版本(可以选择低于自己 cuda 版本的)和 python 版本进行选择。同时选择 abiFALSE。
复制下载链接,在 Linux 中使用 wget 加链接进行 whl 安装包的下载:
wget https://github.com/Dao-AILab/flash-attention/releases/download/v2.6.3/flash_attn-2.6.3+cu123torch2.3cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
最后使用 pip install whl 路径 下载好 flash-attn,完成安装。


