cumulo-autumn / StreamDiffusion

StreamDiffusion: A Pipeline-Level Solution for Real-Time Interactive Generation
Apache License 2.0
9.7k stars 692 forks source link

accelerate_with_tensorrt binding dimension problem? #152

Closed ccarmatic closed 4 months ago

ccarmatic commented 5 months ago

I have tried to use

stream = accelerate_with_tensorrt(
    stream, "engines", max_batch_size=2,
)

, and this is the result image this seems to be the main error message: [E] 3: [executionContext.cpp::nvinfer1::rt::ExecutionContext::validateInputBindings::2045] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::nvinfer1::rt::ExecutionContext::validateInputBindings::2045, condition: profileMaxDims.d[i] >= dimensions.d[i]. Supplied binding dimension [2,4,67,120] for bindings[0] exceed min ~ max range at index 2, maximum dimension in profile is 64, minimum dimension in profile is 64, but supplied dimension is 67. )

ccarmatic commented 5 months ago

I found the problem, it was because I was trying to use a different dimension of image in Streamdiffusion than 512x512

ccarmatic commented 4 months ago

I have solved this problem:

The engine needs to be rebuilt (delete 'engines' folder) , with these arguments passed into accelerate_with_tensorrt :

resolutiondict = {'engine_build_options' : {'opt_image_height': HEIGHT, 'opt_image_width': WIDTH}}
stream = accelerate_with_tensorrt(
    stream, "engines", max_batch_size=BATCH_SIZE,engine_build_options=resolutiondict
)

I think WIDTH and HEIGHT needs to be multiples of 64 , and increasing BATCH_SIZE from 1 can increase performance, but increasing these numbers will increase the VRAM usage of the engine building process, the values working with my RTX4080 with 16GB of RAM are width=832 , height = 512, batch size = 3 , increasing any of these numbers will result in an insufficient memory error when building the engine