坑1:由于升级了cuda (toolkit)导致的import torch报错
由于之前为了适配flash_attn对于nvcc -V 11.7的要求,已经cuda toolkit的版本升级到了12.0
cuda (toolkit) 12.0 + cuda driver 12.0 + torch 2.5,2.4的各版本,报下面这个错:
ImportError: /user_root/envs/verl yi/lib/python3.10/site-packages/torch/lib/../../nvidia/cusparse/lib/1ibcusparse.so.12: undefined symbol: __nvJitLinkConplete_12_4, version libnyJitLi
采用了网上说加软链接的方法对我来说行不通,最后我选择更换torch版本,才成功import torch。具体而言,我把torch的版本换成了torch2.6和torch2.7。我最后用的是torch2.6+cu118。
使用如下的命令直接安装,详情请见pytorch get start:
# 此版本是torch2.6+cu118
pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu118
坑2:torch2.7+flash_attn 2.8.0.post2报错
刚开始我尝试配置的版本是torch2.7+flash_attn 2.8.0.post2组合,但报错:
ImportError: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32'
网上查了一下(具体网址),说是由ubuntu版本太低导致的。
我看了下服务器的ubuntu的版本,满足要求。但GLIBC版本仅2.31。
网上查了下GLIBC的升级略麻烦,因此选择降低flash_attn版本到2.7.4.post1,因此我把torch跟着降级到了torch2.6+cu118 ,成功!
这里附上flash_attn安装方法(参考了多个教程总结的)
安装好 pytorch 以后:
pip install packaging
pip install ninja
接下来到以下链接,挑选whl(以下链接是v2.7.4.post1),下载后上传到服务器上(看准你的torch版本,cuda版本,和python版本):
https://github.com/Dao-AILab/flash-attention/releases/tag/v2.7.4.post1
pip install 你下载的.whl
即可成功安装flash_attn
坑3:一切顺利,但import flash_attn的时候报错
如下:
ImportError: This modeling file requires the following packages that were not found in your environment: flash_attn.undefined symbol: _ZN3c105ErrorC2ENS_14SourceLocationENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
参考链接https://blog.youkuaiyun.com/chitong18/article/details/144355985
具体解决方案就是下载whl的时候不要安装含TRUE的,而是安装含FALSE的版本。
先卸载原来的版本:pip uninstall flash_attn
然后替换whl:
举例来说,原来我安装的是:
flash_attn-2.7.4.post1+cu12torch2.6cxx11abiTRUE-cp310-cp310-linux_x86_64.whl
改成安装:
flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
pip install flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
1862





