解决50系显卡cuda报错 CUDA error: no kernel image is available & 50系安装Flash attention
摘要:本文介绍了解决CUDA错误"no kernel image"的方法,主要包括:1)重新安装PyTorch指定CUDA版本;2)安装flash-attention时的关键步骤:更新编译工具、卸载ninja、设置CUDA架构参数;3)更新libstdc++库避免运行时错误;4)验证安装的代码示例。这些步骤针对使用特定GPU架构时可能出现的兼容性问题提供了解决方案。
·
CUDA error: no kernel image is available for execution on the device
pip uninstall torch torchvision torchaudio
pip cache purge
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
git clone https://github.com/Dao-AILab/flash-attention
cd flash-attention #进入目录
git submodule update --init --recursive
安装最新的编译工具
pip install --upgrade wheel
卸载ninja工具,否则会编译出错!
pip uninstall ninja
如果你是其他架构的显卡,则将里面的“120”改为该架构对应的代号。
export FLASH_ATTN_CUDA_ARCHS="120"
python setup.py install # 1h
更新conda环境内的 libstdc++ 库,否则运行时会报错,方法如下:
conda install -c conda-forge libstdcxx-ng
try:
import flash_attn
print("flash-attention 已安装,版本:", flash_attn.__version__)
except ImportError:
print("flash-attention 未安装")
更多推荐
所有评论(0)