Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xduzhangjiayu opened this issue Aug 5, 2024 · 3 comments
Open
Labels
bug: triaged [not a bug] This isn't a bug bug Something isn't working

Comments

@xduzhangjiayu
Copy link

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

@xduzhangjiayu xduzhangjiayu added the bug Something isn't working label Aug 5, 2024
@narendasan
Copy link
Collaborator

Seems like this is coming from diffusers: 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. Dont think this involves Torch-TRT

@narendasan narendasan added the bug: triaged [not a bug] This isn't a bug label Aug 5, 2024
@xduzhangjiayu
Copy link
Author

Seems like this is coming from diffusers: 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. Dont think this involves Torch-TRT

Hi,
The strange thing is that when I remove the torch_tensorrt compiled code, using the same prompt and seed, it could generate the correct image.

The GPU i used is RTX4060 Laptop (8GB)
Driver Version: 560.70 CUDA Version: 12.6

@pangyoki
Copy link

pangyoki commented Sep 2, 2024

Has this issue been resolved? I encountered the same issue. And there were no problem when using torch-tensorrt version 2.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: triaged [not a bug] This isn't a bug bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants