Skip to content

Data type mismatch when using stable diffusion in fp16 #993

@ParadoxZW

Description

@ParadoxZW

Describe the bug

When run following code to try stable diffusion v1.5,

from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
       "local_project_path/stable-diffusion-v1-5", 
        torch_dtype=torch.float16, revision="fp16"
)
pipe = pipe.to("cuda")

prompt = "a photo of an astronaut riding a horse on mars"
image = pipe(prompt).images[0]  

I got the error

File "{conda_env_path}/lib/python3.9/site-packages/transformers/models/clip/modeling_clip.py", line 260, in forward
    attn_output = torch.bmm(attn_probs, value_states)
RuntimeError: expected scalar type Half but found Float

Reproduction

No response

Logs

No response

System Info

  • diffusers version: 0.6.0
  • Platform: Linux-4.4.0-31-generic-x86_64-with-glibc2.27
  • Python version: 3.9.11
  • PyTorch version (GPU?): 1.12.0 (True)
  • Huggingface_hub version: 0.10.1
  • Transformers version: 4.20.1
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions