bitsandbytes: CUDA Setup failed despite GPU being available.

===================================BUG REPORT=================================== Welcome to bitsandbytes. For bug reports, please run

python -m bitsandbytes

and submit this information together with your error trace to: https://github.com/TimDettmers/bitsandbytes/issues

bin /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/libbitsandbytes_cuda114.so False CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths… CUDA SETUP: CUDA runtime path found: /usr/local/cuda/lib64/libcudart.so.11.0 CUDA SETUP: Highest compute capability among GPUs detected: 8.0 CUDA SETUP: Detected CUDA version 114 CUDA SETUP: Required library version not found: libbitsandbytes_cuda114.so. Maybe you need to compile it from source? CUDA SETUP: Defaulting to libbitsandbytes_cpu.so…

================================================ERROR===================================== CUDA SETUP: CUDA detection failed! Possible reasons:

  1. CUDA driver not installed
  2. CUDA not installed
  3. You have multiple conflicting CUDA libraries
  4. 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. ================================================================================

CUDA SETUP: Something unexpected happened. Please compile from source: git clone git@github.com:TimDettmers/bitsandbytes.git cd bitsandbytes CUDA_VERSION=114 make cuda11x python setup.py install CUDA SETUP: Setup Failed! /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘}’), PosixPath(‘+’), PosixPath(‘/usr/local/cuda-cuda-11.4/lib64/{LD_LIBRARY_PATH’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: /usr/local/cuda-cuda-11.4/lib64/{LD_LIBRARY_PATH:+:} did not contain [‘libcudart.so’, ‘libcudart.so.11.0’, ‘libcudart.so.12.0’] as expected! Searching further paths… warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘@/tmp/.ICE-unix/3417,unix/A213’), PosixPath(‘local/A213’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘/etc/xdg/xdg-ubuntu’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘1’), PosixPath(‘0’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘/org/gnome/Terminal/screen/0cd87fb5_255b_4afe_a03c_c08838341452’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath(‘module’), PosixPath(‘//matplotlib_inline.backend_inline’)} warn(msg) /home/amax/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cuda_setup/main.py:149: 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’ll flip a coin and try one of these, in order to fail forward. Either way, this might cause trouble in the future: If you get CUDA error: invalid device function errors, the above might be the cause and the solution is to make sure only one [‘libcudart.so’, ‘libcudart.so.11.0’, ‘libcudart.so.12.0’] in the paths that we search based on your env. warn(msg)

RuntimeError Traceback (most recent call last) Cell In[4], line 1 ----> 1 model = AutoModelForCausalLM.from_pretrained(model_name, quantization_config=quant_config, device_map={“”:0})

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py:490, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs) 488 elif type(config) in cls._model_mapping.keys(): 489 model_class = _get_model_class(config, cls._model_mapping) –> 490 return model_class.from_pretrained( 491 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs 492 ) 493 raise ValueError( 494 f"Unrecognized configuration class {config.class} for this kind of AutoModel: {cls.name}.\n" 495 f"Model type should be one of {', '.join(c.name for c in cls._model_mapping.keys())}." 496 )

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/transformers/modeling_utils.py:2681, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs) 2678 keep_in_fp32_modules = [] 2680 if load_in_8bit or load_in_4bit: -> 2681 from .utils.bitsandbytes import get_keys_to_not_convert, replace_with_bnb_linear 2683 llm_int8_skip_modules = quantization_config.llm_int8_skip_modules 2684 load_in_8bit_fp32_cpu_offload = quantization_config.llm_int8_enable_fp32_cpu_offload

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/transformers/utils/bitsandbytes.py:11 7 from .import_utils import importlib_metadata, is_accelerate_available, is_bitsandbytes_available 10 if is_bitsandbytes_available(): —> 11 import bitsandbytes as bnb 12 import torch 13 import torch.nn as nn

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/init.py:6 1 # Copyright © Facebook, Inc. and its affiliates. 2 # 3 # This source code is licensed under the MIT license found in the 4 # LICENSE file in the root directory of this source tree. ----> 6 from . import cuda_setup, utils, research 7 from .autograd._functions import ( 8 MatmulLtState, 9 bmm_cublas, (…) 13 matmul_4bit 14 ) 15 from .cextension import COMPILED_WITH_CUDA

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/research/init.py:1 ----> 1 from . import nn 2 from .autograd._functions import ( 3 switchback_bnb, 4 matmul_fp8_global, 5 matmul_fp8_mixed, 6 )

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/research/nn/init.py:1 ----> 1 from .modules import LinearFP8Mixed, LinearFP8Global

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/research/nn/modules.py:8 5 from torch import Tensor, device, dtype, nn 7 import bitsandbytes as bnb ----> 8 from bitsandbytes.optim import GlobalOptimManager 9 from bitsandbytes.utils import OutlierTracer, find_outlier_dims 11 T = TypeVar(“T”, bound=“torch.nn.Module”)

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/optim/init.py:6 1 # Copyright © Facebook, Inc. and its affiliates. 2 # 3 # This source code is licensed under the MIT license found in the 4 # LICENSE file in the root directory of this source tree. ----> 6 from bitsandbytes.cextension import COMPILED_WITH_CUDA 8 from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit 9 from .adam import Adam, Adam8bit, Adam32bit, PagedAdam, PagedAdam8bit, PagedAdam32bit

File ~/.local/share/virtualenvs/py3env-AC0QPwS-/lib/python3.8/site-packages/bitsandbytes/cextension.py:20 18 CUDASetup.get_instance().generate_instructions() 19 CUDASetup.get_instance().print_log_stack() —> 20 raise RuntimeError(‘’’ 21 CUDA Setup failed despite GPU being available. Please run the following command to get more information: 22 23 python -m bitsandbytes 24 25 Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them 26 to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes 27 and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues’‘’) 28 lib.cadam32bit_grad_fp32 # runs on an error if the library could not be found -> COMPILED_WITH_CUDA=False 29 lib.get_context.restype = ct.c_void_p

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. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 5
  • Comments: 23 (1 by maintainers)

Most upvoted comments

Try this: it’s worked for me in Window 10.

pip uninstall bitsandbytes
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.0-py3-none-win_amd64.whl

Upgrading via pip install -U bitsandbytes should resolve this issue. I will close this issue. Please reopen if upgrading does not resolve the error.

exactly the same error for me - you may have to downgrade to 0.38.x (this will not have 4 bit training though)

Try this: it’s worked for me in Window 10.

pip uninstall bitsandbytes
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.0-py3-none-win_amd64.whl

This solution works for me.

Still receiving this with the latest version. Using GCP Workbench Managed Notebook (with PyTorch kernel) and this is what I get:

===================================BUG REPORT===================================
================================================================================
The following directories listed in your path were found to be non-existent: {PosixPath('/usr/local/nvidia/lib64'), PosixPath('/usr/local/lib/x86_64-linux-gnu'), PosixPath('/usr/local/cuda/lib'), PosixPath('/usr/local/nvidia/lib')}
The following directories listed in your path were found to be non-existent: {PosixPath('pytorch-gpu/1-12+cu113')}
The following directories listed in your path were found to be non-existent: {PosixPath('/proxy/%PORT%')}
The following directories listed in your path were found to be non-existent: {PosixPath('/proxy/%PORT%')}
The following directories listed in your path were found to be non-existent: {PosixPath('//matplotlib_inline.backend_inline'), PosixPath('module')}
CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths...
DEBUG: Possible options found for libcudart.so: {PosixPath('/usr/local/cuda/lib64/libcudart.so'), PosixPath('/usr/local/cuda/lib64/libcudart.so.11.0')}
CUDA SETUP: PyTorch settings found: CUDA_VERSION=113, Highest Compute Capability: 8.0.
CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md
CUDA SETUP: Required library version not found: libbitsandbytes_cuda113.so. Maybe you need to compile it from source?
CUDA SETUP: Defaulting to libbitsandbytes_cpu.so...

================================================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`.
================================================================================

CUDA SETUP: Something unexpected happened. Please compile from source:
git clone https://github.com/TimDettmers/bitsandbytes.git
cd bitsandbytes
CUDA_VERSION=113 make cuda11x
python setup.py install
CUDA SETUP: Setup Failed!
/opt/conda/lib/python3.7/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: Welcome to bitsandbytes. For bug reports, please run

python -m bitsandbytes


  warn(msg)
/opt/conda/lib/python3.7/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: /opt/conda did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...
  warn(msg)
/opt/conda/lib/python3.7/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'), PosixPath('/usr/local/cuda/lib64/libcudart.so.11.0')}.. 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
  warn(msg)
/opt/conda/lib/python3.7/site-packages/bitsandbytes/cuda_setup/main.py:166: UserWarning: /usr/local/cuda/lib64:/usr/local/cuda/lib:/usr/local/lib/x86_64-linux-gnu:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64 did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths...
  warn(msg)

Building it manually doesn’t resolve the issue.

This is my LD_LIBRARY_PATH:

‘/usr/local/cuda/lib64:/usr/local/cuda/lib:/usr/local/lib/x86_64-linux-gnu:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64’

and libcudart.so actually exist in /usr/local/cuda/lib64

@ChensStudio thank you so much.

Adding the below lines at the end of .bahrc file saved me from getting the same error.

export CUDA_HOME=/usr/local/cuda-11.8
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:/usr/lib/wsl/lib
export PATH=$CUDA_HOME/bin:$PATH

It was a classic scope problem again. Script can’t find the cuda location. I spent my hours to solve that. I really appreciate your help 🙏

Hi @matterphiz I am getting this same error when I am running the following code

from peft import LoraConfig, get_peft_model

Can you please provide a fix to this.

Thanks!

Downgraded to 0.38.1, exact same error.

Compiled from source code. same error here when run python -m bitsandbytes

using CUDA11.8 python 3.10

===================================BUG REPORT=================================== Welcome to bitsandbytes. For bug reports, please run

python -m bitsandbytes

and submit this information together with your error trace to: https://github.com/TimDettmers/bitsandbytes/issues

bin /usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/libbitsandbytes_cpu.so False CUDA exception! Error code: no CUDA-capable device is detected CUDA exception! Error code: initialization error CUDA SETUP: CUDA runtime path found: /usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudart.so.11.0 /usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/cuda_setup/main.py:149: UserWarning: WARNING: No GPU detected! Check your CUDA paths. Proceeding to load CPU-only library… warn(msg) CUDA SETUP: Detected CUDA version 118 CUDA SETUP: Required library version not found: libbitsandbytes_cpu.so. Maybe you need to compile it from source? CUDA SETUP: Defaulting to libbitsandbytes_cpu.so…

================================================ERROR===================================== CUDA SETUP: CUDA detection failed! Possible reasons:

  1. CUDA driver not installed
  2. CUDA not installed
  3. You have multiple conflicting CUDA libraries
  4. 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.

CUDA SETUP: Something unexpected happened. Please compile from source: git clone git@github.com:TimDettmers/bitsandbytes.git cd bitsandbytes CUDA_VERSION=118 make cuda11x_nomatmul python setup.py install CUDA SETUP: Setup Failed! Traceback (most recent call last): File “/usr/lib/python3.10/runpy.py”, line 187, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File “/usr/lib/python3.10/runpy.py”, line 146, in _get_module_details return _get_module_details(pkg_main_name, error) File “/usr/lib/python3.10/runpy.py”, line 110, in _get_module_details import(pkg_name) File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/init.py”, line 6, in from . import cuda_setup, utils, research File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/research/init.py”, line 1, in from . import nn File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/research/nn/init.py”, line 1, in from .modules import LinearFP8Mixed, LinearFP8Global File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/research/nn/modules.py”, line 8, in from bitsandbytes.optim import GlobalOptimManager File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/optim/init.py”, line 6, in from bitsandbytes.cextension import COMPILED_WITH_CUDA File “/usr/local/lib/python3.10/dist-packages/bitsandbytes-0.39.0-py3.10.egg/bitsandbytes/cextension.py”, line 20, in raise RuntimeError(‘’’ 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. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

Got fixed. btw, I am using WSL2 in windows.

Have it fixed by downgrade to python 3.8 (may not be the root cause), and reinstall CUDA 11.8

And set below env export CUDA_HOME=/usr/local/cuda-11.8 export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:/usr/lib/wsl/lib export PATH=$CUDA_HOME/bin:$PATH