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:
- CUDA driver not installed
- CUDA not installed
- You have multiple conflicting CUDA libraries
- Required library not pre-compiled for this bitsandbytes release!
CUDA SETUP: If you compiled from source, try again with
make CUDA_VERSION=DETECTED_CUDA_VERSIONfor example,make CUDA_VERSION=113. CUDA SETUP: The CUDA version for the compile might depend on your conda install. Inspect CUDA version viaconda 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)
Try this: it’s worked for me in Window 10.
Upgrading via
pip install -U bitsandbytesshould 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)
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:
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
.bahrcfile saved me from getting the same error.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.
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