Stable Diffusion 3 single file safetensors model with 8b quantized T5xxl returns zeroes, black image
Describe the bug
Loading sd3_medium_incl_clips_t5xxlfp8.safetensors like the official example generates a black image of zeroes.
People in community found same to be happening with fp16 model as well.
Related huggingface thread: https://huggingface.co/stabilityai/stable-diffusion-3-medium/discussions/161
Reproduction
import torch
from diffusers import StableDiffusion3Pipeline
import cv2
import numpy as np
pipe = StableDiffusion3Pipeline.from_single_file(
"https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/sd3_medium_incl_clips_t5xxlfp8.safetensors",
torch_dtype=torch.float16,
)
print('model loaded')
pipe = pipe.to('cuda')
image = pipe(
"A cat holding a sign that says hello world",
negative_prompt="",
num_inference_steps=10,
guidance_scale=7.0,
).images[0]
image.save('image.jpg')
Logs
No response
System Info
More details found here https://huggingface.co/stabilityai/stable-diffusion-3-medium/discussions/161
Who can help?
@yiyixuxu @sayakpaul @DN6 @asomoza
It works in Kaggle's notebook with this environment:
- 🤗 Diffusers version: 0.29.2
- Platform: Linux-5.15.154+-x86_64-with-glibc2.31
- Python version: 3.10.13
- PyTorch version (GPU?): 2.1.2 (True)
- Flax version (CPU?/GPU?/TPU?): 0.8.4 (gpu)
- Jax version: 0.4.26
- JaxLib version: 0.4.26.dev20240504
- Huggingface_hub version: 0.23.4
- Transformers version: 4.42.3
- Accelerate version: 0.32.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.3
- xFormers version: not installed
- Accelerator: Tesla P100-PCIE-16GB, 16384 MiB VRAM
I had to use pipe.enable_model_cpu_offload() rather than pipe = pipe.to('cuda').
Could you share the result of this command: diffusers-cli env?
Edit 1: When I try with torch==2.3.1+cu121, it gives black images :/
Edit 2: When I install diffusers from the source, it works again.
Edit 3: Duplicate of #8759.
Hi @hnhparitosh can you try installing diffusers from main and rerunning your code?
pip install --upgrade git+https://github.com/huggingface/diffusers.git
seems that installing diffusers from git makes the code run as expected.
Also, had to use pipe.enable_model_cpu_offload() rather than pipe = pipe.to('cuda').
Thanks! Closing now