bitsandbytes-foundation / bitsandbytes

Accessible large language models via k-bit quantization for PyTorch.
https://huggingface.co/docs/bitsandbytes/main/en/index
MIT License
6.19k stars 621 forks source link

CUDA detection failed. Either CUDA driver not installed, CUDA not installed, or you have multiple conflicting CUDA libraries! #109

Closed enn-nafnlaus closed 9 months ago

enn-nafnlaus commented 1 year ago

Got an error saying that either CUDA driver is not installed (I run CUDA apps on the GPU regularly, including StableDiffusion), CUDA is not installed (same), or I have multiple conflicting CUDA libraries (I don't). bitsandbytes == 0.35.4.

_BUG REPORT Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues For effortless bug reporting copy-paste your error into this form: https://docs.google.com/forms/d/e/1FAIpQLScPB8emS3Thkp66nvqwmjTEgxp8Y9ufuWTzFyr9kJ5AoI47dQ/viewform?usp=sf_link

CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching /usr/local/cuda/lib64... CUDA SETUP: CUDA runtime path found: /usr/local/cuda/lib64/libcudart.so CUDA SETUP: Highest compute capability among GPUs detected: 8.6 CUDA SETUP: Detected CUDA version 120 CUDA SETUP: TODO: compile library for specific version: libbitsandbytes_cuda120.so CUDA SETUP: Defaulting to libbitsandbytes.so... CUDA SETUP: CUDA detection failed. Either CUDA driver not installed, CUDA not installed, or you have multiple conflicting CUDA libraries! CUDA SETUP: If you compiled from source, try again with make CUDA_VERSION=DETECTED_CUDA_VERSION for example, make CUDA_VERSION=113. Exception importing 8bit adam: CUDA SETUP: Setup Failed! WARNING:extensions.sd_dreambooth_extension.dreambooth.train_dreambooth:Exception importing 8bit adam: CUDA SETUP: Setup Failed! Traceback (most recent call last): File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/extensions/sd_dreambooth_extension/dreambooth/train_dreambooth.py", line 597, in main import bitsandbytes as bnb File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/init.py", line 6, in from .autograd._functions import ( File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/autograd/_functions.py", line 5, in import bitsandbytes.functional as F File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/functional.py", line 13, in from .cextension import COMPILED_WITH_CUDA, lib File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/cextension.py", line 41, in lib = CUDALibrary_Singleton.get_instance().lib File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/cextension.py", line 37, in get_instance cls.instance.initialize() File "/scratch/StableDiffusion/AUTOMATIC1111/stable-diffusion-webui/venv/lib64/python3.10/site-packages/bitsandbytes/cextension.py", line 27, in initialize raise Exception('CUDA SETUP: Setup Failed!') Exception: CUDA SETUP: Setup Failed!

Installed:

cuda-toolkit-11-config-common-11.8.89-1.noarch libcudnn8-8.0.4.30-1.cuda11.1.x86_64 nvidia-driver-cuda-libs-525.60.13-1.fc36.x86_64 nvidia-driver-cuda-525.60.13-1.fc36.x86_64 cuda-toolkit-12-config-common-12.0.107-1.noarch cuda-toolkit-12-0-config-common-12.0.107-1.noarch cuda-cudart-12-0-12.0.107-1.x86_64 cuda-opencl-12-0-12.0.76-1.x86_64 cuda-nvrtc-12-0-12.0.76-1.x86_64 cuda-libraries-12-0-12.0.0-1.x86_64 cuda-nvprof-12-0-12.0.90-1.x86_64 cuda-nvml-devel-12-0-12.0.76-1.x86_64 cuda-nvdisasm-12-0-12.0.76-1.x86_64 cuda-cccl-12-0-12.0.90-1.x86_64 cuda-cudart-devel-12-0-12.0.107-1.x86_64 cuda-nvvp-12-0-12.0.90-1.x86_64 cuda-nvrtc-devel-12-0-12.0.76-1.x86_64 cuda-opencl-devel-12-0-12.0.76-1.x86_64 cuda-nsight-systems-12-0-12.0.0-1.x86_64 cuda-nsight-compute-12-0-12.0.0-1.x86_64 cuda-profiler-api-12-0-12.0.76-1.x86_64 cuda-nvtx-12-0-12.0.76-1.x86_64 cuda-nvprune-12-0-12.0.76-1.x86_64 cuda-nvcc-12-0-12.0.76-1.x86_64 cuda-nsight-12-0-12.0.78-1.x86_64 cuda-gdb-12-0-12.0.90-1.x86_64 cuda-driver-devel-12-0-12.0.107-1.x86_64 cuda-libraries-devel-12-0-12.0.0-1.x86_64 cuda-visual-tools-12-0-12.0.0-1.x86_64 cuda-documentation-12-0-12.0.76-1.x86_64 cuda-demo-suite-12-0-12.0.76-1.x86_64 cuda-cuxxfilt-12-0-12.0.76-1.x86_64 cuda-cupti-12-0-12.0.90-1.x86_64 cuda-cuobjdump-12-0-12.0.76-1.x86_64 cuda-compiler-12-0-12.0.0-1.x86_64 cuda-sanitizer-12-0-12.0.90-1.x86_64 cuda-command-line-tools-12-0-12.0.0-1.x86_64 cuda-tools-12-0-12.0.0-1.x86_64 cuda-toolkit-12-0-12.0.0-1.x86_64 cuda-toolkit-config-common-12.0.107-1.noarch

Nvidia driver installed from the runtime rather than rpm (necessary - the dependency chains have been a nightmare on FC36).

tanvirh commented 1 year ago

I got the same errors. This may be related to this other issue. I managed to fix this by:

  1. removing the pip installed bitsandbytes
  2. adding cuda to my LD_LIBRARY_PATH, eg: export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH
  3. compile and install bitsandbytes from source, but "make all" failed for me so I had to do "make cuda11x" instead, eg: git clone https://github.com/TimDettmers/bitsandbytes.git cd bitsandbytes CUDA_VERSION=120 make cuda11x python setup.py install

Good luck! It reduced the GPU memory required by 3-4X, very useful!

caldwecg commented 1 year ago

I'm encountering this error when executing make within bitsandbytes. Any ideas?

ptxas info : Used 2 registers, 320 bytes cmem[0] /usr/include/c++/11/bits/std_function.h:435:145: error: parameter packs not expanded with ‘...’: 435 | function(_Functor&& f) | ^ /usr/include/c++/11/bits/std_function.h:435:145: note: ‘_ArgTypes’ /usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’: 530 | operator=(_Functor&& f) | ^ /usr/include/c++/11/bits/std_function.h:530:146: note: ‘_ArgTypes’

Tahreezz commented 1 year ago

CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching /usr/local/cuda/lib64... D:\Stable\LORa\kohya_ss\venv\lib\site-packages\bitsandbytes\cuda_setup\paths.py:27: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {WindowsPath('/usr/local/cuda/lib64')}

what can I do I have already installed it

tensiondriven commented 1 year ago

Running into the same issue, still debugging. FWIW, I dearly appriciate how thorough the error message is @TimDettmers - Good lookin out for the user!

keelangibb commented 1 year ago

I am on windows. I had a similar problem trying to run a different model with pytorch but this might help. Ensure you have a supported cuda version with pytorch e.g. 11.8 . And have installed pytorch 11.8 with the anaconda command from the docs. Then run these commands.

  1. pip uninstall bitsandbytes
  2. pip install git+https://github.com/Keith-Hon/bitsandbytes-windows.git
a373648449 commented 1 year ago

1、pip uninstall bitsandbytes 2、pip install bitsandbytes-cuda116 3、https://pypi.org/project/bitsandbytes-cuda116/

cookie925 commented 1 year ago

I am on windows. I had a similar problem trying to run a different model with pytorch but this might help. Ensure you have a supported cuda version with pytorch e.g. 11.8 . And have installed pytorch 11.8 with the anaconda command from the docs. Then run these commands.

  1. pip uninstall bitsandbytes
  2. pip install git+https://github.com/Keith-Hon/bitsandbytes-windows.git

thank u !!!I have been trying to find this version of bitsandbytes, but I haven't found it before.

ihongxx commented 12 months ago

$ sudo apt install gcc-10 g++-10 $ export CC=/usr/bin/gcc-10 $ export CXX=/usr/bin/g++-10 $ export CUDA_ROOT=/usr/local/cuda $ ln -s /usr/bin/gcc-10 $CUDA_ROOT/bin/gcc $ ln -s /usr/bin/g++-10 $CUDA_ROOT/bin/g++ $ git clone https://github.com/timdettmers/bitsandbytes.git $ cd bitsandbytes $ CUDA_HOME=/usr/local/cuda-11.6 CUDA_VERSION=116 make cuda11x $ python setup.py install I succeeded!

swumagic commented 11 months ago

Bitsandbytes was not supported windows before, but my method can support windows.(yuhuang) 1 open folder J:\StableDiffusion\sdwebui,Click the address bar of the folder and enter CMD or WIN+R, CMD 。enter,cd /d J:\StableDiffusion\sdwebui 2 J:\StableDiffusion\sdwebui\py310\python.exe -m pip uninstall bitsandbytes

3 J:\StableDiffusion\sdwebui\py310\python.exe -m pip uninstall bitsandbytes-windows

4 J:\StableDiffusion\sdwebui\py310\python.exe -m pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.1-py3-none-win_amd64.whl

Replace your SD venv directory file(python.exe Folder) here(J:\StableDiffusion\sdwebui\py310)

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.