[踩坑记] CUDA环境下bitsandbytes安装报错/异常解决

关键词:模型量化,bitsandbytes,bitsandbytes报错,大模型环境,CUDA环境

1. 问题描述

在部署大模型LLaMA的过程中,需要安装量化工具包bitsandbytes,环境如下:
操作系统:Ubuntu 18.04
GPU:4xA100 40G
CUDA:11.7
cuDNN:8.4
bitsandbytes: 0.38.0
github库

conda python环境下,通过pip install bitsandbytes直接安装,或是按源码编译安装,在python -m bitsandbytes检测时均出现异常。详见ISSUES),主要异常内容如下:

File 'bitsandbytes/cextension.py', line 20, in <module> raise RuntimeError('''
RuntimeError:
CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs above to fix your environment!
''')

在环境变量LD_LIBRARY_PATH中增加CUDA的lib路径,问题依旧。重新编译出现异常内容如下:

nvcc fatal: Unsupported gpu architecture 'compute_75'

在环境变量中增加CUDA_HOME,编译成功,但执行模块加载后出依然出现问题:

RuntimeError:
CUDA Setup failed despite GPU being available. Please run the following command to get more information: 

python -m bitsandbytes

Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them to your LD_LIBRARY_PATH. ...

bitsandbytes仓库中发布ISSUES,无论是增加环境变量,还是重新编译,均没有解决。

2. 过程分析

新环境安装:在另外一台GPU测试机GTX TITAN X(lspci | grep -i nvidia)上安装CUDA11.7和cuDNN,并安装bitsandbytes(python -m bitsandbytes),一切正常。

确定问题出在系统环境上,咨询OP环境情况,原来系统中安装了CUDA10后来没有删除又安装了CUDA11,删除CUDA10后,可能系统中有信息残留,导致上述各种问题的出现,总之就是CUDA环境不干净!

3. 解决方法 ISSUES

删除系统中的所有的CUDA程序,包括源码安装的和工具安装的CUDA(apt-get uninstall),确保nvidia-smi, nvcc不再可用。

重新在干净的系统上依次安装cuDNNCUDA,之后重启系统,在conda python环境下通过pip install bitsandbytes安装bitsandbytes,通过python -m bitsandbytes验证,安装成功。

——– END ——–

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年5月29日
下一篇 2023年5月29日

相关推荐