Skip to content
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

AttributeError: 'tensorrt_bindings.tensorrt.ICudaEngine' object has no attribute 'max_batch_size' #4293

Closed
kratos231245 opened this issue Dec 20, 2024 · 4 comments
Labels
question Further information is requested triaged Issue has been triaged by maintainers

Comments

@kratos231245
Copy link

It seems that in TensorRT 10.7, there is no tensorrt_bindings.tensorrt.ICudaEngine.max_batch_size API. Are there any other APIs that can replace this one?

@lix19937
Copy link

Implicit batch is no longer supported.

@brnguyen2
Copy link
Collaborator

Hi @kratos231245 , please refer to https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/work-dynamic-shapes.html#specifying-runtime-dimensions for the currently supported APIs for specifying input shapes in TensorRT.

Closing this issue, please open a new ticket if you have additional questions.

@brnguyen2 brnguyen2 added question Further information is requested triaged Issue has been triaged by maintainers labels Feb 11, 2025
@yansiyu550
Copy link

Hi @kratos231245 , please refer to https://docs.nvidia.com/deeplearning/tensorrt/latest/inference-library/work-dynamic-shapes.html#specifying-runtime-dimensions for the currently supported APIs for specifying input shapes in TensorRT.

Closing this issue, please open a new ticket if you have additional questions.

self.batch_size = engine.max_batch_size
AttributeError: 'tensorrt_bindings.tensorrt.ICudaEngine' object has no attribute 'max_batch_size'

How can I fix it?

@brnguyen2
Copy link
Collaborator

@yansiyu550 Beginning with newer versions of TensorRT (often referred to as the “explicit batch” API), the batch size is treated as an explicit dimension of the input tensor. For instance, if your network input originally has the dimensions [H, W, C] (height, width, channels), in TensorRT with an explicit batch size it becomes [B, H, W, C], where B is the batch dimension.

To retrieve the shape of any input tensor (including the batch size), you can use the engine.get_tensor_shape API. The shape it returns will include this batch dimension as the first element.

When working with dynamic shapes, note that the maximum allowed input dimensions are constrained by the optimization profile configured in the engine. Each optimization profile specifies minimum, optimal, and maximum dimensions for each input. For details on setting up and using optimization profiles, refer to the TensorRT documentation on dynamic shapes and optimization profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants