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

bindings[0] exceed min ~ max range at index 3 #859

Open
jihad-akl opened this issue May 5, 2023 · 2 comments
Open

bindings[0] exceed min ~ max range at index 3 #859

jihad-akl opened this issue May 5, 2023 · 2 comments

Comments

@jihad-akl
Copy link

I converted a torch model with multiple input but it is not working

input_shape = (1, 3 , 32, 96)
input_tensor = torch.ones(input_shape).cuda()
print("creating engine")
engine = torch2trt(self.net, [input_tensor], min_shape= [(1, 3, 32, 32)],max_shape= [(1, 3, 960, 960)],fp16_mode= True)
print("engine done")
torch.save(engine.state_dict(), 'model.pth')

the model is created but in inference if i give a shape other than (1, 3 , 32, 96) i get an error:

[05/05/2023-07:45:37] [TRT] [E] 3: [executionContext.cpp::setBindingDimensions::966] Error Code 3: API Usage Error (Parameter check failed at: runtime/api/executionContext.cpp::setBindingDimensions::966, condition: profileMinDims.d[i] <= dimensions.d[i]. Supplied binding dimension [1,3,32,64] for bindings[0] exceed min ~ max range at index 3, maximum dimension in profile is 96, minimum dimension in profile is 96, but supplied dimension is 64.

@jihad-akl
Copy link
Author

Update: putting s to min_shape and max_shape it result to an error:

creating engine
/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py:3728: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.")
[05/05/2023-11:29:34] [TRT] [E] 3: [network.cpp::addPoolingNd::1025] Error Code 3: API Usage Error (Parameter check failed at: optimizer/api/network.cpp::addPoolingNd::1025, condition: allDimsGtEq(windowSize, 1) && volume(windowSize) < MAX_KERNEL_DIMS_PRODUCT(nbSpatialDims)
)
Traceback (most recent call last):
File "test_to_ocr_torch_tensorrt.py", line 10, in
model = TextSystem(args=ModelArgs(det_model_path=det_model_path, use_gpu=True,
File "/test/PytorchOCR/text_system.py", line 16, in init
self.text_detector = TextDetector(args, **kwargs)
File "/test/PytorchOCR/text_detector.py", line 270, in init
engine = torch2trt(self.net, [input_tensor], min_shapes= [(1, 3, 32, 32)], max_shapes= [(1, 3, 960, 960)],fp8_mode= True)
File "/opt/conda/lib/python3.8/site-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/torch2trt.py", line 778, in torch2trt
outputs = module(*inputs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1204, in _call_impl
result = forward_call(*input, **kwargs)
File "/test/PytorchOCR/modeling/architectures/base_model.py", line 88, in forward
x = self.neck(x)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1204, in _call_impl
result = forward_call(*input, **kwargs)
File "/test/PytorchOCR/modeling/necks/db_fpn.py", line 214, in forward
in5 = self.ins_conv3
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1204, in _call_impl
result = forward_call(*input, **kwargs)
File "/test/PytorchOCR/modeling/necks/db_fpn.py", line 184, in forward
out = x + self.se_block(x)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1204, in _call_impl
result = forward_call(*input, **kwargs)
File "/test/PytorchOCR/modeling/backbones/det_mobilenet_v3.py", line 71, in forward
outputs = self.avg_pool(inputs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1204, in _call_impl
result = forward_call(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/torch2trt.py", line 310, in wrapper
converter"converter"
File "/opt/conda/lib/python3.8/site-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/converters/AdaptiveAvgPool2d.py", line 22, in convert_AdaptiveAvgPool2d
layer.stride = stride
AttributeError: 'NoneType' object has no attribute 'stride'

@vjixy
Copy link

vjixy commented May 5, 2023

I am facing the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants