How to support dynamic batch size for TensorRT engine?


In the doc, it’s said that EXPLICIT_BATCH must be specified for onnx exported network. So, is there any way to support dynamic batch size for engine built by this network?

For example, I build this engine with batch size 16. Now I want to run it in Python with batch size 8. Is there any method?

Request you to share the ONNX model and the script if not shared already so that we can assist you better.
Alongside you can try few things:

  1. validating your model with the below snippet

import sys
import onnx
filename = yourONNXmodel
model = onnx.load(filename)
2) Try running your model with trtexec command.

In case you are still facing issue, request you to share the trtexec “”–verbose"" log for further debugging