当前位置:   article > 正文

关于bitsandbytes安装报错_cuda setup failed despite gpu being available. ple

cuda setup failed despite gpu being available. please run the following comm

RunTimeError:CUDA Setup failed despite GPU being available. Inspect the CUDA SETUP outputs above to fix your environment!

  1. ubuntu@VM-0-8-ubuntu:~$ python -m bitsandbytes
  2. False
  3. ===================================BUG REPORT===================================
  4. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: Welcome to bitsandbytes. For bug reports, please run
  5. python -m bitsandbytes
  6. warn(msg)
  7. ================================================================================
  8. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: /home/ubuntu/anaconda3/envs/pytorch200 did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...
  9. warn(msg)
  10. CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths...
  11. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: Found duplicate ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] files: {PosixPath('/usr/local/cuda/lib64/libcudart.so.11.0'), PosixPath('/usr/local/cuda/lib64/libcudart.so')}.. We select the PyTorch default libcudart.so, which is {torch.version.cuda},but this might missmatch with the CUDA version that is needed for bitsandbytes.To override this behavior set the BNB_CUDA_VERSION=<version string, e.g. 122> environmental variableFor example, if you want to use the CUDA version 122BNB_CUDA_VERSION=122 python ...OR set the environmental variable in your .bashrc: export BNB_CUDA_VERSION=122In the case of a manual override, make sure you set the LD_LIBRARY_PATH, e.g.export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.2
  12. warn(msg)
  13. DEBUG: Possible options found for libcudart.so: {PosixPath('/usr/local/cuda/lib64/libcudart.so.11.0'), PosixPath('/usr/local/cuda/lib64/libcudart.so')}
  14. CUDA SETUP: PyTorch settings found: CUDA_VERSION=117, Highest Compute Capability: 7.0.
  15. CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
  16. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: WARNING: Compute capability < 7.5 detected! Only slow 8-bit matmul is supported for your GPU! If you run into issues with 8-bit matmul, you can try 4-bit quantization: https://huggingface.co/blog/4bit-transformers-bitsandbytes
  17. warn(msg)
  18. CUDA SETUP: Loading binary /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda117_nocublaslt.so...
  19. libcusparse.so.11: cannot open shared object file: No such file or directory
  20. CUDA SETUP: Something unexpected happened. Please compile from source:
  21. git clone https://github.com/TimDettmers/bitsandbytes.git
  22. cd bitsandbytes
  23. CUDA_VERSION=117 make cuda11x_nomatmul
  24. python setup.py install
  25. Traceback (most recent call last):
  26. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 187, in _run_module_as_main
  27. mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  28. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 146, in _get_module_details
  29. return _get_module_details(pkg_main_name, error)
  30. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 110, in _get_module_details
  31. __import__(pkg_name)
  32. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/__init__.py", line 6, in <module>
  33. from . import cuda_setup, utils, research
  34. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/__init__.py", line 1, in <module>
  35. from . import nn
  36. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/nn/__init__.py", line 1, in <module>
  37. from .modules import LinearFP8Mixed, LinearFP8Global
  38. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/nn/modules.py", line 8, in <module>
  39. from bitsandbytes.optim import GlobalOptimManager
  40. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/optim/__init__.py", line 6, in <module>
  41. from bitsandbytes.cextension import COMPILED_WITH_CUDA
  42. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/cextension.py", line 20, in <module>
  43. raise RuntimeError('''
  44. RuntimeError:
  45. CUDA Setup failed despite GPU being available. Please run the following command to get more information:
  46. python -m bitsandbytes
  47. Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
  48. to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
  49. and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

关于微调大语言模型绕不开安装bitsandbytes,有很多小伙伴会报以上的error

参考GitHub上bitsandbytes的issue  https://github.com/TimDettmers/bitsandbytes/issues/305

发现很多人给了一些错误的方向,实际问题就是CUDA环境不干净,参考CSDN回答[踩坑记] CUDA环境下bitsandbytes安装报错/异常解决

这位用户提供的解决方法是:删除系统中的所有的CUDA程序重新在干净的系统上依次安装cuDNNCUDA

我尝试了一种新的思路,或许不用删除CUDA程序(因为隐患很大)

0.以下闲聊,可以直接skip to 1.

在重新配置.bashrc之后

source .bashrc

导致我退出了虚拟环境,偶然进入了系统环境,然后离奇的发现安装完bitsandbytes之后可以直接进行python -m bitsandbytes显示安装成功。

然后我再次进入虚拟环境还是报错。

猜测因为虚拟环境中的环境配置文件是跟系统中的环境配置文件不是使用的一个文件(所以无论我怎么改系统的环境配置都没用),或许我们只需要在现有的CUDA环境中删除conda文件夹(不确定路径保存在哪里,可能是在.condarc中?所以尝试全部删除),新建conda虚拟环境导入CUDA-11.X的路径即可,经过实验确实可行

1.删除conda安装文件夹

可以通过以下命令查看文件位置

(pytorch200) ubuntu@VM-0-8-ubuntu:~$ conda info

2.重新安装conda

3.创建新的虚拟环境

step2,3参考如何在Linux服务器上安装Anaconda(超详细)_linux安装anaconda_黄瓜炒肉的博客-CSDN博客

4.配置LD_LIBRARY_PATH

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

这里我的cuda版本是11.7,可以根据实际CUDA版本进行更改,注意 只能执行这个命令一次,请谨慎使用,否则会出现:/usr/local/cuda-11.7/lib64:/usr/local/cuda-11.7/lib64 找不到路径或者文件的error

5.运行python -m bitsandbytes

可能会出现 如下报错

  1. ubuntu@VM-0-8-ubuntu:~$ python -m bitsandbytes
  2. Traceback (most recent call last):
  3. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 187, in _run_module_as_main
  4. mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  5. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 146, in _get_module_details
  6. return _get_module_details(pkg_main_name, error)
  7. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/runpy.py", line 110, in _get_module_details
  8. __import__(pkg_name)
  9. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/__init__.py", line 6, in <module>
  10. from . import cuda_setup, utils, research
  11. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/__init__.py", line 1, in <module>
  12. from . import nn
  13. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/nn/__init__.py", line 1, in <module>
  14. from .modules import LinearFP8Mixed, LinearFP8Global
  15. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/research/nn/modules.py", line 8, in <module>
  16. from bitsandbytes.optim import GlobalOptimManager
  17. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/optim/__init__.py", line 8, in <module>
  18. from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit
  19. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/optim/adagrad.py", line 5, in <module>
  20. from bitsandbytes.optim.optimizer import Optimizer1State
  21. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/optim/optimizer.py", line 12, in <module>
  22. import bitsandbytes.functional as F
  23. File "/home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/functional.py", line 12, in <module>
  24. from scipy.stats import norm
  25. ModuleNotFoundError: No module named 'scipy'

6.安装scipy

pip install scipy

7.调试bitsandbytes是否可用

  1. ubuntu@VM-0-8-ubuntu:~$ python -m bitsandbytes
  2. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  3. ++++++++++++++++++ BUG REPORT INFORMATION ++++++++++++++++++
  4. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5. +++++++++++++++++++ ANACONDA CUDA PATHS ++++++++++++++++++++
  6. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
  7. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libc10_cuda.so
  8. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libtorch_cuda_linalg.so
  9. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda117.so
  10. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda114_nocublaslt.so
  11. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda110.so
  12. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda115.so
  13. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda115_nocublaslt.so
  14. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda111.so
  15. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda114.so
  16. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda120_nocublaslt.so
  17. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda111_nocublaslt.so
  18. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118_nocublaslt.so
  19. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda121_nocublaslt.so
  20. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122_nocublaslt.so
  21. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda121.so
  22. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda117_nocublaslt.so
  23. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda110_nocublaslt.so
  24. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122.so
  25. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118.so
  26. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda120.so
  27. ++++++++++++++++++ /usr/local CUDA PATHS +++++++++++++++++++
  28. /usr/local/cuda-11.7/nsight-compute-2022.2.1/target/linux-desktop-glibc_2_19_0-ppc64le/libcuda-injection.so
  29. /usr/local/cuda-11.7/nsight-compute-2022.2.1/target/linux-desktop-t210-a64/libcuda-injection.so
  30. /usr/local/cuda-11.7/nsight-compute-2022.2.1/target/linux-desktop-glibc_2_11_3-x64/libcuda-injection.so
  31. /usr/local/cuda-11.7/targets/x86_64-linux/lib/stubs/libcuda.so
  32. /usr/local/cuda-11.7/targets/x86_64-linux/lib/libcudart.so
  33. +++++++++++++++ WORKING DIRECTORY CUDA PATHS +++++++++++++++
  34. /home/ubuntu/anaconda3/lib/libicudata.so
  35. /home/ubuntu/anaconda3/pkgs/icu-58.2-h9c2bf20_1/lib/libicudata.so
  36. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libtorch_cuda.so
  37. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libc10_cuda.so
  38. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/torch/lib/libtorch_cuda_linalg.so
  39. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda117.so
  40. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda114_nocublaslt.so
  41. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda110.so
  42. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda115.so
  43. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda115_nocublaslt.so
  44. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda111.so
  45. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda114.so
  46. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda120_nocublaslt.so
  47. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda111_nocublaslt.so
  48. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118_nocublaslt.so
  49. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda121_nocublaslt.so
  50. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122_nocublaslt.so
  51. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda121.so
  52. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda117_nocublaslt.so
  53. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda110_nocublaslt.so
  54. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda122.so
  55. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda118.so
  56. /home/ubuntu/anaconda3/envs/pytorch200/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cuda120.so
  57. /home/ubuntu/.local/lib/python3.8/site-packages/torch/lib/libtorch_cuda.so
  58. /home/ubuntu/.local/lib/python3.8/site-packages/torch/lib/libc10_cuda.so
  59. /home/ubuntu/.local/lib/python3.8/site-packages/torch/lib/libtorch_cuda_linalg.so
  60. ++++++++++++++++++ LD_LIBRARY CUDA PATHS +++++++++++++++++++
  61. ++++++++++ /usr/local/cuda-11.7/lib64 CUDA PATHS +++++++++++
  62. ++++++++++++++++++++++++++ OTHER +++++++++++++++++++++++++++
  63. COMPILED_WITH_CUDA = True
  64. COMPUTE_CAPABILITIES_PER_GPU = ['7.0']
  65. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  66. ++++++++++++++++++++++ DEBUG INFO END ++++++++++++++++++++++
  67. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  68. Running a quick check that:
  69. + library is importable
  70. + CUDA function is callable
  71. WARNING: Please be sure to sanitize sensible info from any such env vars!
  72. SUCCESS!
  73. Installation was successful!

8.bitsandbytes安装成功

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/688525
推荐阅读
相关标签
  

闽ICP备14008679号