Skip to content

🐛 [Bug] SDv1.5 generate black image with torch_tensorrt compile #3059

@xduzhangjiayu

Description

@xduzhangjiayu

Bug Description

SDv1.5 generate black image with torch_tensorrt compile

log on cmd:
Lib\site-packages\diffusers\image_processor.py:97: RuntimeWarning: invalid value encountered in cast
images = (images * 255).round().astype("uint8")
Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.

To Reproduce

Follow the official example:
`import torch
import torch_tensorrt
from diffusers import DiffusionPipeline
model_id = "stable-diffusion-v1-5"
device = "cuda:0"
pipe = DiffusionPipeline.from_pretrained(
model_id, revision="fp16", torch_dtype=torch.float16
)
pipe = pipe.to(device)

backend = "torch_tensorrt"
pipe.unet = torch.compile(
pipe.unet,
backend=backend,
options={
"truncate_long_and_double": True,
"enabled_precisions": {torch.float32, torch.float16},
},
dynamic=False,
)`

Expected behavior

SDv1.5 generate a normal image

Environment

tensorrt 10.1.0
tensorrt-cu12 10.2.0.post1
tensorrt-cu12_bindings 10.1.0
tensorrt-cu12_libs 10.1.0
torch 2.4.0+cu124
torch_tensorrt 2.4.0
torchaudio 2.4.0+cu124
torchvision 0.19.0+cu124

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions