大模型GPU安装bitsandbytes报错解决

文章讲述了在部署大模型LLaMA/Qwen-7B时,用户遇到在Ubuntu22.04系统上使用bitsandbytes工具包的安装问题,主要原因是CUDA版本不匹配。通过添加CUDA和cuDNN的库路径到环境变量并重新安装bitsandbytes,解决了这个问题并成功训练模型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 问题描述


在部署大模型LLaMA/Qwen-7B的过程中,需要安装量化工具包bitsandbytes,环境如下:
操作系统:Ubuntu 22.04
GPU:4xA100 80G
CUDA:11.7
cuDNN:8.0
bitsandbytes: 0.41.0 

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

============================ERROR=====================
CUDA SETUP: CUDA detection failed! Possible reasons:
1. You need to manually override the PyTorch CUDA version. Please see: "https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
2. CUDA driver not installed
3. CUDA not installed
4. You have multiple conflicting CUDA libraries
5. Required library not pre-compiled for this bitsandbytes release!
CUDA SETUP: If you compiled from source, try again with `make CUDA_VERSION=DETECTED_CUDA_VERSION` for example, `make CUDA_VERSION=113`.
CUDA SETUP: The CUDA version for the compile might depend on your conda install. Inspect CUDA version via `conda list | grep cuda`.
=======================================================

2. 问题解决

在环境变量LD_LIBRARY_PATH中增加CUDA的lib路径:

export PATH=/usr/local/cuda-11.7/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH 

然后重新安装bitsandbytes即可:

pip uninstall bitsandbytes
pip install bitsandbytes

最后正常加载模型并训练:

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值