Text-to-Image
Diffusers
Safetensors
StableDiffusionPipeline
stable-diffusion
Inference Endpoints

Only generates black images?

#9
by shawnrushefsky - opened

Loading saved model downloaded from stabilityai/stable-diffusion-2-1

stable_2_1 = StableDiffusionPipeline.from_pretrained(
  "/var/app/models/ldm/sd-2-1/",
  torch_dtype=float16
  ).to("cuda")
stable_2_1.enable_attention_slicing()

All I am getting is black images, running code that worked with 1.5. I'm using an A10 gpu. It is not flagging them as NSFW, and it takes a normal amount of time to do the generation.

have you run this?
pip install --upgrade git+https://github.com/huggingface/diffusers.git transformers accelerate scipy

My GPU is T4 16G, and it worked with 2.0 after I upgraded

I did run that. Also installed xformers, but that also did not make a difference

In the past I'd resolved that by switching to the correct YAML, but this was working last night and isn't this morning ..

In the process of figuring that out now ..

Loading saved model downloaded from stabilityai/stable-diffusion-2-1

stable_2_1 = StableDiffusionPipeline.from_pretrained(
  "/var/app/models/ldm/sd-2-1/",
  torch_dtype=float16
  ).to("cuda")
stable_2_1.enable_attention_slicing()

All I am getting is black images, running code that worked with 1.5. I'm using an A10 gpu. It is not flagging them as NSFW, and it takes a normal amount of time to do the generation.

I met the same problem, have you solved it? Thank you.

Same here! Black images, working greate with 2.0 but after update always black

I resolved it by using torch_dtype=float32 instead of torch_dtype=float16

try using --no-half as argument

I resolved it by using torch_dtype=float32 instead of torch_dtype=float16

Sadly this did not work for me.

try using --no-half as argument

I'm not using a desktop gui, I'm running python code in the cloud.

Hey, please make sure to run the newest version of diffusers (0.10.0) so that the Q K matrices are automatically upcasted to float to prevent overflow and thus black images.

Upgrading from 0.9.0 solved a warning about "upcast attention", but not the issue of black images.

I was running the pipe in awith autocast("cuda") context from Stable Diffusion v1.4 examples. This needed to be removed.

The example has been updated since I referred to it, so no action needed. Thanks! https://huggingface.co/CompVis/stable-diffusion-v1-4/discussions/148/files

@justinbowes you are my hero. Removed the autocast, everything working great now.

shawnrushefsky changed discussion status to closed

i followed the zip file version of the local install and just don't know enough about how to update things. Could anyone explain what to do for a total noob?

I use SD2.1 without with autocast("cuda"), when setting the dimension float16 I get black squares, with float32 everything works fine, but the generation speed decreases by 2 times. Does anyone know a way how to solve the problem?

Same problem - black images despite no autocast and stuff, with xformers on fp16

If anybody has code they can share, I’m happy to take a look. I haven’t had any problems with 2.1 since updating diffusers and getting rid of autocast. I’m using fp16 on a10 gpus w/ xformers

i'm fixed as:
./webui.sh --no-half

i'm fixed as:
./webui.sh --no-half

Not a fix for me as I own a low VRAM GPU: 3060 laptop 6 GB. So, I believe I should stick to v1.5 :(

I too was facing the same problem, as mentioned above the solution is to change the torch_dtype from torch.float16 to torch.float32

Sign up or log in to comment