Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colab code not running in linux (issue with libtorch_cuda_cpp.so and xformers) #36

Open
gozi1123 opened this issue Oct 13, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@gozi1123
Copy link

Describe the bug

trying to run the colab code in linux but getting error

first:
libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory
WARNING:root:WARNING: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory
Need to compile C++ extensions to get sparse attention suport. Please run python setup.py build develop

later:
RuntimeError: No such operator xformers::efficient_attention_forward_generic - did you forget to build xformers with python setup.py develop?
what am I doing wrong?

Reproduction

created a new conda env and ran the lines:

pip install -qq git+https://github.com/ShivamShrirao/diffusers
pip install -q -U --pre triton
pip install -q accelerate==0.12.0 transformers ftfy bitsandbytes gradio
pip install https://github.com/metrolobo/xformers_wheels/releases/download/1d31a3ac_various_6/xformers-0.0.14.dev0-cp37-cp37m-linux_x86_64.whl

then ran the code (using bash):

accelerate launch train_dreambooth.py
--pretrained_model_name_or_path=$MODEL_NAME
--instance_data_dir=$INSTANCE_DIR
--class_data_dir=$CLASS_DIR
--output_dir=$OUTPUT_DIR
--with_prior_preservation --prior_loss_weight=1.0
--instance_prompt="photo of sapirmo {CLASS_NAME}"
--class_prompt="photo of a {CLASS_NAME}"
--seed=1337
--resolution=512
--train_batch_size=1
--mixed_precision="fp16"
--use_8bit_adam
--gradient_accumulation_steps=1
--learning_rate=5e-6
--lr_scheduler="constant"
--lr_warmup_steps=0
--num_class_images=50
--sample_batch_size=4
--max_train_steps=1000
--gradient_checkpointing

Logs

bash train_booth.sh 
libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory
WARNING:root:WARNING: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory
Need to compile C++ extensions to get sparse attention suport. Please run python setup.py build develop
Fetching 16 files: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 16/16 [00:00<00:00, 32832.13it/s]
The config attributes {'feature_extractor': ['transformers', 'CLIPFeatureExtractor'], 'safety_checker': ['stable_diffusion', 'StableDiffusionSafetyChecker']} were passed to StableDiffusionPipeline, but are not expected and will be ignored. Please verify your model_index.json configuration file.
Generating class images:   0%|                                                                                                                                                                                                                                            | 0/13 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "train_dreambooth.py", line 638, in <module>
    main()
  File "train_dreambooth.py", line 381, in main
    images = pipeline(example["prompt"]).images
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py", line 312, in __call__
    noise_pred = self.unet(latent_model_input, t, encoder_hidden_states=text_embeddings).sample
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/models/unet_2d_condition.py", line 286, in forward
    encoder_hidden_states=encoder_hidden_states,
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/models/unet_blocks.py", line 565, in forward
    hidden_states = attn(hidden_states, context=encoder_hidden_states)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/models/attention.py", line 154, in forward
    hidden_states = block(hidden_states, context=context)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/models/attention.py", line 203, in forward
    hidden_states = self.attn1(self.norm1(hidden_states)) + hidden_states
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/diffusers/models/attention.py", line 276, in forward
    hidden_states = xformers.ops.memory_efficient_attention(query, key, value)
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/xformers/ops.py", line 575, in memory_efficient_attention
    query=query, key=key, value=value, attn_bias=attn_bias, p=p
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/xformers/ops.py", line 196, in forward_no_grad
    causal=isinstance(attn_bias, LowerTriangularMask),
  File "/home/galgozes/anaconda3/envs/dreambooth/lib/python3.7/site-packages/xformers/ops.py", line 46, in no_such_operator
    f"No such operator xformers::{name} - did you forget to build xformers with `python setup.py develop`?"
RuntimeError: No such operator xformers::efficient_attention_forward_generic - did you forget to build xformers with `python setup.py develop`?

System Info

  • diffusers version: 0.5.0.dev0
  • Platform: Linux-5.4.0-1087-gcp-x86_64-with-debian-buster-sid
  • Python version: 3.7.13
  • PyTorch version (GPU?): 1.12.1+cu102 (True)
  • Huggingface_hub version: 0.10.1
  • Transformers version: 4.23.1
@gozi1123 gozi1123 added the bug Something isn't working label Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant