Skip to content

[BUG - STABLE DIFFUSION 3] Grey images generated #10040

Closed
@hoangvictor

Description

@hoangvictor

Describe the bug

I'm running the SD3 model stabilityai/stable-diffusion-3-medium with the following settings:

  • Height: 1024
  • Width: 1024
  • Inference steps: 50
  • Guidance scale: 7
  • Prompts length: 32 (using the same input prompt: "A men jumps from a high building")

The model generates 32 images, but half of them are grey.

Reproduction

Reproduction code:

import os

os.environ['CUDA_VISIBLE_DEVICES'] = '7'

import torch
from diffusers import StableDiffusion3Pipeline

base_dir = os.path.join(os.path.dirname(__file__), '..', '..')

def run():
    input_prompts = ["A men jumps from a high building"] * 32
    img_save_dir = f'{base_dir}/data/test_generated_img'
    os.makedirs(f'{img_save_dir}', exist_ok=True)

    pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium-diffusers", torch_dtype=torch.float16, cache_dir="/data0/tien/cache")
    pipe.to("cuda")

    torch.set_grad_enabled(False)
    images = pipe(
        prompt=input_prompts,
        negative_prompt="",
        height=1024,
        width=1024,
        num_inference_steps=50,
        guidance_scale=7.0
    ).images

    for j in range(len(input_prompts)):
        images[j].save(os.path.join(f'{img_save_dir}', f'{j}.jpg'))

    torch.cuda.empty_cache()
    
run()

Logs

No response

System Info

  • Device: H100
  • Driver Version: 550.127.05
  • CUDA Version: 12.4
  • Torch: 2.5.1+cu124
  • OS: Ubuntu 22.04.3 LTS
  • Python: 3.10.15
  • diffusers: 0.31.0

Who can help?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions