[已解决] flash-attn报错flash_attn_2_cuda.cpython-310-x86_64-linux-gnu.so: undefined symbol

报错信息

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

  1. 卸载已有的flash-attn, 输入pip uninstall flash-attn, 然后输入y
  2. 查看自己对应的torch版本,cuda版本和python版本

查看torch版本

pip show torch

返回如下结果,可知torch版本为2.3.1
在这里插入图片描述

查看cuda版本

nvcc -V

在这里插入图片描述
cuda版本为V12.5.40

查看python版本

python --version
  1. 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,大功告成!

猜你喜欢

转载自blog.csdn.net/a61022706/article/details/141570792