Skip to content

Black image on SDXL 1.0 + RuntimeWarning: invalid value encountered in cast images = (images * 255).round().astype("uint8") #4325

@belfortf

Description

@belfortf

Describe the bug

I'm trying to run SDXL in a container environment (Debian). I tried both diffusers[torch]==0.18.0 and diffusers[torch]==0.19.0 with Python 3.10 on A10g and A100 but I get a black image back and RuntimeWarning: invalid value encountered in cast
images = (images * 255).round().astype("uint8") when running 0.18.0.

Basically, when building the container's image I'm doing:

 pipe = diffusers.DiffusionPipeline.from_pretrained(
        model_id,
        use_auth_token=hugging_face_token,
        torch_dtype=torch.float16,
        use_safetensors=True, 
        variant="fp16",
        cache_dir=cache_path
    )
pipe.save_pretrained(cache_path, safe_serialization=True)

After that, when running the function I'm calling:

self.pipe = diffusers.DiffusionPipeline.from_pretrained(
            cache_path).to("cuda")

With 0.19.0 I'm getting Out of memory errors. .enable_model_cpu_offload() didn't work for me. Anyway, with both versions in the end I get a black image.

Reproduction

pipe = diffusers.DiffusionPipeline.from_pretrained(
        model_id,
        use_auth_token=hugging_face_token,
        torch_dtype=torch.float16,
        use_safetensors=True, 
        variant="fp16",
        cache_dir=cache_path
    )
pipe.save_pretrained(cache_path, safe_serialization=True)
    
pipe = diffusers.DiffusionPipeline.from_pretrained(
            cache_path).to("cuda")

Logs

The config attributes {'force_upcast': True} were passed to AutoencoderKL, but are not expected and will be ignored. Please verify your config.json configuration file.
 98%|█████████▊| 49/50 [00:10<00:00,  5.28it/s]100%|██████████| 50/50 [00:10<00:00,  5.27it/s]100%|██████████| 50/50 [00:10<00:00,  4.90it/s]
/usr/local/lib/python3.10/site-packages/diffusers/image_processor.py:65: RuntimeWarning: invalid value encountered in cast
  images = (images * 255).round().astype("uint8")

System Info

0.18.0 and 0.19.0. Linux Debian (don't have access to the container now).

Who can help?

@patrickvonplaten

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions