解决llama factory运行报错:The installed version of bitsandbytes was compiled without GPU support亲测可用

搞llama factory时环境出了问题,运行时会提示
The installed version of bitsandbytes was compiled without GPU support.
尝试了网上各种方法都没有,后来发现是torch装错了版本,由于llama factory采用并行计算 bitsandbytes 无法使用gpu引起的问题

  1. 首先确定安装好了cuda,控制台敲 nvcc -V 如果有返回结果就说明成功安装了
    在这里插入图片描述

  2. 然后查看torch是否支持gpu,依次在命令行中敲入,或直接编写py脚本执行均可。

python
improt torch
print(torch.cuda.isavailabel)

如果返回ture就是支持,如果返回false就是不支持,说明cuda没搞好

  1. 安装gpu版本的torch
    去这个网站上找好对应版本的指令:https://pytorch.org/get-started/previous-versions/
    与我环境契合的指令是 conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia

出现了新的问题
在这里插入图片描述
在安装时提示入口错误。经过排查发现是安装途径有问题。直接执行这个命令修改安装途径

conda-forge::libarchive```

再次尝试安装torch,提示缺少chardet、prompt库,好吧,手动安装

conda install prompt
conda install chardet


再次尝试安装,又说cuda version不支持python版本=3.9.x  好吧,再修改下当前环境的python版本

conda install python=3.8

再次执行安装
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/64bd861f7a2b43a495af875f91efdbc1.png)
终于成功了
再次执行llama factory,不再出现不支持gpu的提示了

4. 该方法处理有可能会导致pytorch加载的其他库无法运行,只需pip uninstall xxxx, pip install xxxx 对目标库进行重新安装即可解决,下列是我遇到的实际出现问题的库

```python
sentencepiece
safetensors
 pydantic_core
orjson
pandas
 pyarrow
multiprocess
xxhash
 matplotlib
kiwisolver
regex
scipy

/home/saman/anaconda3/envs/pytorch1110/bin/python /root/autodl-tmp/Llama_finance/finetune_qlora.py The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable. CUDA is required but not available for bitsandbytes. Please consider installing the multi-platform enabled version of bitsandbytes, which is currently a work in progress. Please check currently supported platforms and installation instructions at https://huggingface.co/docs/bitsandbytes/main/en/installation#multi-backend Traceback (most recent call last): File "/root/autodl-tmp/Llama_finance/finetune_qlora.py", line 15, in <module> model = AutoModelForCausalLM.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 571, in from_pretrained return model_class.from_pretrained( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/modeling_utils.py", line 279, in _wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4228, in from_pretrained hf_quantizer.validate_environment( File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/quantizers/quantizer_bnb_4bit.py", line 84, in validate_environment validate_bnb_backend_availability(raise_exception=True) File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/integrations/bitsandbytes.py", line 561, in validate_bnb_backend_availability return _validate_bnb_cuda_backend_availability(raise_exception) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/saman/anaconda3/envs/pytorch1110/lib/python3.11/site-packages/transformers/
最新发布
05-05
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

千年奇葩

从来没受过打赏,这玩意好吃吗?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值