TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

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

Open xduzhangjiayu opened this issue 1 year ago • 3 comments

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 avatar Aug 05 '24 06:08 xduzhangjiayu

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 avatar Aug 05 '24 20:08 narendasan

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

xduzhangjiayu avatar Aug 05 '24 23:08 xduzhangjiayu

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

pangyoki avatar Sep 02 '24 04:09 pangyoki