comfyanonymous / ComfyUI_TensorRT

MIT License
513 stars 34 forks source link

all SD3 engines generate black images randomly (almost all of the time) #25

Closed Shaistrong closed 5 months ago

Shaistrong commented 5 months ago

the it/s certainly speed up dramatically using the engines, but there is no use for that if the engines output pitch black images most of the time. and bs>1 engines (or have it in their range) never output anything but black boxes.

bc6 commented 5 months ago

I can confirm that the vast majority of images generated are black, and some of them are fine in early steps but turn into black later on during the generation. This bug renders the entire toolset useless for SD3.

al-swaiti commented 5 months ago

same here

al-swaiti commented 5 months ago

hi again try to start comfyui without any flags , and then rebuild tensor t

al-swaiti commented 5 months ago

my setup image

Meizr commented 5 months ago

I've tried to edit function in samplers.py like this:

https://github.com/comfyanonymous/ComfyUI_TensorRT/issues/5#issuecomment-2153601378

But it doesn't work. It seems like with this edit, sometimes (probably when black result would appear if function wasn't modified) results differ from normal and eventually, a black result occurs

Shaistrong commented 5 months ago

hi again try to start comfyui without any flags , and then rebuild tensor t

I already tried that, it also resulted in an engine that occasionally makes black boxes. not a fix.

Meizr commented 5 months ago

Has anyone that has this issue updated to pytorch 2.3?

gseth commented 5 months ago

Same here:

[06/17/2024-01:53:18] [TRT] [E] 3: [executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068, condition: satisfyProfile Runtime dimension does not satisfy any optimization profile.)

It outputs at double the speed though.

At random seed, it keeps giving black images half the time, and proper images rest of the time. Can't figure it out.

Meizr commented 5 months ago

[06/17/2024-01:53:18] [TRT] [E] 3: [executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068, condition: satisfyProfile Runtime dimension does not satisfy any optimization profile.)

I don't see that error here. I only see a cast warning, but it seems like it's just because the image is a bunch of NaNs when it's being saved.

It outputs at double the speed though.

I didn't get such an improvement. I went from 4.20 it/s to 4.90 it/s. Not such a big deal.

I suspect if I rebuild the engines the same way, performance might be better (or worse)

gseth commented 5 months ago

[06/17/2024-01:53:18] [TRT] [E] 3: [executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::nvinfer1::rt::ExecutionContext::setInputShape::2068, condition: satisfyProfile Runtime dimension does not satisfy any optimization profile.)

I don't see that error here. I only see a cast warning, but it seems like it's just because the image is a bunch of NaNs when it's being saved.

It outputs at double the speed though.

I didn't get such an improvement. I went from 4.20 it/s to 4.90 it/s. Not such a big deal.

I suspect if I rebuild the engines the same way, performance might be better (or worse)

I did a 1024 with a batch of 4, probably that's why. And what workflow are you using. When I use the Dual Clip Loader it doesn't give that error but all 4 images are black.

If I use the triple clip loader I get that error but images are black at random. I am testing in batches of 4, 1024x1024.

Meizr commented 5 months ago

I did a 1024 with a batch of 4, probably that's why. And what workflow are you using. When I use the Dual Clip Loader it doesn't give that error but all 4 images are black.

If I use the triple clip loader I get that error but images are black at random. I am testing in batches of 4, 1024x1024.

I'm using the "official" workflows: https://comfyanonymous.github.io/ComfyUI_examples/sd3/

I've only tested with triple clip.

chenlimyim commented 5 months ago

I also encountered the same problem, all the images were white noise or black, but on SD1.5, the images were normal.

geroldmeisinger commented 5 months ago

same here. black images half of the time.

comfyanonymous commented 5 months ago

It should be fixed now by: https://github.com/comfyanonymous/ComfyUI_TensorRT/commit/41e28c6d62db9e34922c44df25a5ccacc849382c