question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: /opt/conda/bin/python: undefined symbol: cudaRuntimeGetVersion

See original GitHub issue

Describe the bug

AttributeError: /opt/conda/bin/python: undefined symbol: cudaRuntimeGetVersion

Reproduction

%cd /workspace

!git clone https://github.com/huggingface/diffusers.git
%cd /workspace/diffusers/examples/dreambooth

!pwd
pip install -U -r requirements.txt
!pip install bitsandbytes
!git config --global credential.helper store

from huggingface_hub import notebook_login
notebook_login()
MODEL_NAME_OR_PATH="CompVis/stable-diffusion-v1-4"
# MODEL_NAME_OR_PATH="runwayml/stable-diffusion-v1-5"
# MODEL_NAME_OR_PATH="runwayml/stable-diffusion-inpainting"
INSTANCE_DIR="./instance_images"
CLASS_DIR="./class_images"
OUTPUT_DIR="./trained_model"
INSTANCE_PROMPT="a photo of sks dog"
CLASS_PROMPT="a photo of dog"
NUM_CLASS_IMAGES=200
MAX_TRAIN_STEPS=800
SEED=1337

# Ensure the directories have been created
!mkdir -p $INSTANCE_DIR
!mkdir -p $CLASS_DIR
!mkdir -p $OUTPUT_DIR

!accelerate launch train_dreambooth.py \
  --pretrained_model_name_or_path="$MODEL_NAME_OR_PATH"  \
  --instance_data_dir="$INSTANCE_DIR" \
  --class_data_dir="$CLASS_DIR" \
  --output_dir="$OUTPUT_DIR" \
  --with_prior_preservation --prior_loss_weight=1.0 \
  --instance_prompt="$INSTANCE_PROMPT" \
  --class_prompt="$CLASS_PROMPT" \
  --resolution=512 \
  --train_batch_size=1 \
  --gradient_accumulation_steps=2 --gradient_checkpointing \
  --use_8bit_adam \
  --learning_rate=5e-6 \
  --lr_scheduler="constant" \
  --lr_warmup_steps=0 \
  --num_class_images="$NUM_CLASS_IMAGES" \
  --max_train_steps="$MAX_TRAIN_STEPS" \
  --seed=$SEED

Logs

Traceback (most recent call last):
  File "train_dreambooth.py", line 668, in <module>
    main(args)
  File "train_dreambooth.py", line 454, in main
    import bitsandbytes as bnb
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/__init__.py", line 6, in <module>
    from .autograd._functions import (
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/autograd/_functions.py", line 5, in <module>
    import bitsandbytes.functional as F
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/functional.py", line 13, in <module>
    from .cextension import COMPILED_WITH_CUDA, lib
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/cextension.py", line 113, in <module>
    lib = CUDASetup.get_instance().lib
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/cextension.py", line 109, in get_instance
    cls._instance.initialize()
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/cextension.py", line 59, in initialize
    binary_name, cudart_path, cuda, cc, cuda_version_string = evaluate_cuda_setup()
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/cuda_setup/main.py", line 125, in evaluate_cuda_setup
    cuda_version_string = get_cuda_version(cuda, cudart_path)
  File "/opt/conda/lib/python3.7/site-packages/bitsandbytes/cuda_setup/main.py", line 45, in get_cuda_version
    check_cuda_result(cuda, cudart.cudaRuntimeGetVersion(ctypes.byref(version)))
  File "/opt/conda/lib/python3.7/ctypes/__init__.py", line 377, in __getattr__
    func = self.__getitem__(name)
  File "/opt/conda/lib/python3.7/ctypes/__init__.py", line 382, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))

AttributeError: /opt/conda/bin/python: undefined symbol: cudaRuntimeGetVersion


### System Info

diffusers-cli env

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

  • diffusers version: 0.7.2
  • Platform: Linux-5.15.0-52-generic-x86_64-with-debian-buster-sid
  • Python version: 3.7.13
  • PyTorch version (GPU?): 1.13.0+cu117 (True)
  • Huggingface_hub version: 0.10.1
  • Transformers version: 4.24.0
  • Using GPU in script?: RTX 3090
  • Using distributed or parallel set-up in script?: No

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
0xdevaliascommented, Nov 9, 2022

Just found this, so maybe it’s an issue with bitsandbytes:

Was able to workaround this with setenv LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu which is where my libcudart.so is (Ubuntu 22.04). Not sure why it misses that.

_Originally posted by @tshadley in https://github.com/TimDettmers/bitsandbytes/issues/85#issuecomment-1304840335_

I had this error and was stumped by it until I realised that my CUDA toolkit had been installed ~incorrectly and was in a place where bitsandbytes couldn’t find it. So when I installed PyTorch and the toolkit via conda instead of pip, the library was able to locate the toolkit and this error went away.

_Originally posted by @65536william in https://github.com/TimDettmers/bitsandbytes/issues/85#issuecomment-1307529648_

1reaction
patrickvonplatencommented, Nov 9, 2022

Hey @0xdevalias,

Yes indeed I think this is a bitsandbytes issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - AttributeError: /usr/sbin/httpd: undefined symbol ...
I have a website that runs python code with Flask and mod_wsgi. I set the WSGIDaemonProcess user and group and the WSGIProcessGroup. Recently, ......
Read more >
python undefined symbol - OceanHero
Issue 210701: undefined symbol in custom interpeter (PR#191) - Python . ... AttributeError: /opt/conda/bin/python: undefined symbol ... unaclad.com ...
Read more >
[Solved]Undefined symbol: cudaGetDevice - Questions
When trying to execute “Get Started with TVM” example, following error occurred: import tvm import numpy as np # Global declarations of environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found