pytorch / pytorch/TensorRT

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

Open
#3,059 3 comments 0 reactions 1 assignee View on GitHub

@narendasan is already working on this.

Since Jul 30, 2026.

bug bug: triaged [not a bug] story: LLM & Generative AI
Dominant language
Python
Stars
3k
Forks
410
Avg merge
3d 18h
Merged PRs (30d)
78

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.