-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Why TensorRT 8.5 and TensorRT 8.6 do not support dynamic shape input during the calibration? #3933
Comments
@lix19937 May I have your help? Thank you very much! |
Usually dynamic shape calib use opt shape, when you use cpp IInt8EntropyCalibrator2 or IInt8MinMaxCalibrator. BTW, NV think un-opt shape is not allowed. |
Thanks a lot for the help. I see, this error is related to the version of polygraphy, instaed of TensorRT. But with the version of 0.33.0 polygraphy, it works fine with dynamic input shape for calibration, and both the version of 0.43.1 and 0.47.1 polygraphy will raise the error, but the CHANGELOG said the bug have been fixed since version 0.44.2 ("Fixed a bug where the calibrator would not accept inputs with a shape other than the OPT shape set in the profile." ), it quite strange... |
Check the impl of function of get_batch in backend/trt/calibrator.py, for example, as polygraphy v0.33.0, https://github.com/NVIDIA/TensorRT/blob/release/8.0/tools/Polygraphy/polygraphy/backend/trt/calibrator.py#L118 has no check about of input shapes. but for polygraphy v0.42.1, if not util.is_valid_shape_override(buffer.shape, expected_shape):
G_LOGGER.critical(
err_prefix
+ f"For input: '{name}', expected a shape compatible with: {expected_shape}, but received: {buffer.shape}"
) If you overwrite Calibrator, there is no limit about the input shapes except the batch size. |
BTW: NV constraint
|
Oh,I see,got it,Your kindness is so appreciated. Thank you ever so much! |
@lix19937 Sorry bother again. After overwrite Calibrator in TensorRT 8.6, the calibration can be successfully done and generate the calibration cache file, but can not build the quantilized tensorrt engine, give the following error:
Why the model can be convert to fp32 tensorrt engine successfully, but failed for int8 quantilization engine? The int8 inference was not implemented in TensorRT8.6 for Tensordot/Reshape node? But why it works fine in TensorRT8.5 and 8.4? |
There are many reasons. I suggest you first use the |
Thanks a lot for the suggestion, but it still give the same error message even use the opt-shape to calib with trt86. It looks like quite complicated...
|
Does |
@lix19937 What is the |
When I use polygraphy to conduct INT8 calibration and quantilization, it failed. Why the TensorRT 8.5 and above version do not support dynamic shape input during the calibration? But it works fine in TensorRT 8.4. For TensorRT 8.5, it gives error like:
And for TensorRT 8.6, it goves error like:
It seems TensorRT 8.5 and 8.6 will only use the optimal shape to conduct calibration? Why? Is there any solution?
The text was updated successfully, but these errors were encountered: