XavierXiao / Dreambooth-Stable-Diffusion

Implementation of Dreambooth (https://arxiv.org/abs/2208.12242) with Stable Diffusion
MIT License
7.57k stars 790 forks source link

CUDA error: CUBLAS_STATUS_NOT_INITIALIZED #113

Closed puhuk closed 1 year ago

puhuk commented 1 year ago

When I run scripts/stable_txt2img.py, it occurs RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling cublasCreate(handle)

Is there way to resolve this.

The full error message is below.

Traceback (most recent call last):
  File "scripts/stable_txt2img.py", line 293, in <module>
    main()
  File "scripts/stable_txt2img.py", line 242, in main
    uc = model.get_learned_conditioning(batch_size * [""])
  File "Dreambooth-Stable-Diffusion/ldm/models/diffusion/ddpm.py", line 595, in get_learned_conditioning
    c = self.cond_stage_model.encode(c, embedding_manager=self.embedding_manager)
  File "Dreambooth-Stable-Diffusion/ldm/modules/encoders/modules.py", line 324, in encode
    return self(text, **kwargs)
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "Dreambooth-Stable-Diffusion/ldm/modules/encoders/modules.py", line 319, in forward
    z = self.transformer(input_ids=tokens, **kwargs)
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "Dreambooth-Stable-Diffusion/ldm/modules/encoders/modules.py", line 297, in transformer_forward
    return self.text_model(
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "Dreambooth-Stable-Diffusion/ldm/modules/encoders/modules.py", line 272, in text_encoder_forward
    last_hidden_state = self.encoder(
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "Dreambooth-Stable-Diffusion/ldm/modules/encoders/modules.py", line 216, in encoder_forward
    layer_outputs = encoder_layer(
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py", line 379, in forward
    hidden_states, attn_weights = self.self_attn(
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lib/python3.8/site-packages/transformers/models/clip/modeling_clip.py", line 268, in forward
    query_states = self.q_proj(hidden_states) * self.scale
  File "/home/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lib/python3.8/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling `cublasCreate(handle)`
puhuk commented 1 year ago

When I follow below command from https://github.com/rinongal/textual_inversion, no more error occurs.

conda env create -f environment.yaml
conda activate ldm