当前位置:   article > 正文

python -m bitsandbytes输出False

python -m bitsandbytes

背景:

使用codeShell

  1. import torch
  2. from transformers import AutoModelForCausalLM, AutoTokenizer
  3. device = 'cuda' if torch.cuda.is_available() else 'cpu'
  4. tokenizer = AutoTokenizer.from_pretrained("codeshell-7b")
  5. model = AutoModelForCausalLM.from_pretrained("codeshell-7b", trust_remote_code=True, torch_dtype=torch.bfloat16).to(device)
  6. inputs = tokenizer('def merge_sort():', return_tensors='pt').to(device)
  7. outputs = model.generate(**inputs)
  8. print(tokenizer.decode(outputs[0]))

安装pip install bitsandbytes后运行仍然报错

  1. False
  2. ===================================BUG REPORT===================================
  3. C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\cuda_setup\main.py:166: UserWarning: Welcome to bitsandbytes. For bug reports, please run
  4. python -m bitsandbytes
  5. warn(msg)
  6. ================================================================================
  7. The following directories listed in your path were found to be non-existent: {WindowsPath('/Anaconda/Anaconda/envs/CodeLLM/lib'), WindowsPath('D')}
  8. C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\cuda_setup\main.py:166: UserWarning: D:\Anaconda\Anaconda\envs\CodeLLM 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. The following directories listed in your path were found to be non-existent: {WindowsPath('/usr/local/cuda/lib64')}
  12. DEBUG: Possible options found for libcudart.so: set()
  13. CUDA SETUP: PyTorch settings found: CUDA_VERSION=118, Highest Compute Capability: 8.9.
  14. CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
  15. CUDA SETUP: Loading binary C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\libbitsandbytes_cuda118.so...
  16. argument of type 'WindowsPath' is not iterable
  17. CUDA SETUP: Problem: The main issue seems to be that the main CUDA runtime library was not detected.
  18. CUDA SETUP: Solution 1: To solve the issue the libcudart.so location needs to be added to the LD_LIBRARY_PATH variable
  19. CUDA SETUP: Solution 1a): Find the cuda runtime library via: find / -name libcudart.so 2>/dev/null
  20. CUDA SETUP: Solution 1b): Once the library is found add it to the LD_LIBRARY_PATH: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:FOUND_PATH_FROM_1a
  21. CUDA SETUP: Solution 1c): For a permanent solution add the export from 1b into your .bashrc file, located at ~/.bashrc
  22. CUDA SETUP: Solution 2: If no library was found in step 1a) you need to install CUDA.
  23. CUDA SETUP: Solution 2a): Download CUDA install script: wget https://github.com/TimDettmers/bitsandbytes/blob/main/cuda_install.sh
  24. CUDA SETUP: Solution 2b): Install desired CUDA version to desired location. The syntax is bash cuda_install.sh CUDA_VERSION PATH_TO_INSTALL_INTO.
  25. CUDA SETUP: Solution 2b): For example, "bash cuda_install.sh 113 ~/local/" will download CUDA 11.3 and install into the folder ~/local
  26. Traceback (most recent call last):
  27. File "<frozen runpy>", line 189, in _run_module_as_main
  28. File "<frozen runpy>", line 148, in _get_module_details
  29. File "<frozen runpy>", line 112, in _get_module_details
  30. File "C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\__init__.py", line 6, in <module>
  31. from . import cuda_setup, utils, research
  32. File "C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\research\__init__.py", line 1, in <module>
  33. from . import nn
  34. File "C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\research\nn\__init__.py", line 1, in <module>
  35. from .modules import LinearFP8Mixed, LinearFP8Global
  36. File "C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\research\nn\modules.py", line 8, in <module>
  37. from bitsandbytes.optim import GlobalOptimManager
  38. RuntimeError:
  39. CUDA Setup failed despite GPU being available. Please run the following command to get more information:
  40. python -m bitsandbytes
  41. Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
  42. to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
  43. and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

查找原因后发现可能是Bitsandbytes以前不支持windows。

解决:

pip install bitsandbytes-windows

之后再运行得到结果:

  1. Explicitly passing a `revision` is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision.
  2. You are using a model of type kclgpt to instantiate a model of type codeshell. This is not supported for all configurations of models and can yield errors.
  3. Explicitly passing a `revision` is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.
  4. ===================================BUG REPORT===================================
  5. Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues
  6. ================================================================================
  7. binary_path: C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\cuda_setup\libbitsandbytes_cuda116.dll
  8. CUDA SETUP: Loading binary C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\bitsandbytes\cuda_setup\libbitsandbytes_cuda116.dll...
  9. Loading checkpoint shards: 100%|██████████| 2/2 [00:12<00:00, 6.09s/it]
  10. Some weights of CodeShellForCausalLM were not initialized from the model checkpoint at codeshell-7b and are newly initialized: ['lm_head.weight']
  11. You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
  12. C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\transformers\generation\utils.py:1201: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation)
  13. warnings.warn(
  14. Setting `pad_token_id` to `eos_token_id`:70000 for open-end generation.
  15. C:\Users\Ma\AppData\Roaming\Python\Python311\site-packages\transformers\generation\utils.py:1288: UserWarning: Using `max_length`'s default (20) to control the generation length. This behaviour is deprecated and will be removed from the config in v5 of Transformers -- we recommend using `max_new_tokens` to control the maximum length of the generation.
  16. warnings.warn(
  17. def merge_sort():潻潻潻潻潻潻潻潻潻潻潻潻潻潻潻

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

闽ICP备14008679号