Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error in converting hybridnets model using torch2trt #918

Open
moscaAle29 opened this issue Mar 5, 2024 · 0 comments
Open

Error in converting hybridnets model using torch2trt #918

moscaAle29 opened this issue Mar 5, 2024 · 0 comments

Comments

@moscaAle29
Copy link

I am encountering an issue when trying to convert a model based on the hybridnets architecture using the torch2trt package. The error seems to be related to the conversion of a convolutional layer, specifically during the convert_Conv_trt7_functional process. I have followed the steps outlined in the documentation and updated both torch and torch2trt to the latest versions, but the problem persists.

Steps to Reproduce:


    import torch
    from torch2trt import torch2trt

    model = torch.hub.load('datvuthanh/hybridnets', 'hybridnets', pretrained=True, device='cuda:0' if torch.cuda.is_available() else 'cpu').eval()
    dummy_input = torch.ones(1, 3, 384, 640).cuda()
    model_trt = torch2trt(model, [dummy_input], fp16_mode=True)
Observe the error during the conversion process.

Environment:

Operating System: Ubuntu 20.04 LTS
Python Version: 3.8.10
PyTorch Version: 2.1.2
torch2trt Version: 0.4.2

Error Traceback:
Traceback (most recent call last):
File "/home/user/Scrivania/H2politO/h2seg/compile_network.py", line 12, in
model_trt = torch2trt(model, [dummy_input], fp16_mode=True)
File "/usr/local/lib/python3.8/dist-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/torch2trt.py", line 779, in torch2trt
outputs = module(*inputs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
result = forward_call(*args, **kwargs)
File "/home/user/.cache/torch/hub/datvuthanh_hybridnets_main/backbone.py", line 109, in forward
p2, p3, p4, p5 = self.encoder(inputs)[-4:] # self.backbone_net(inputs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
result = forward_call(*args, **kwargs)
File "/home/user/.cache/torch/hub/datvuthanh_hybridnets_main/encoders/efficientnet.py", line 73, in forward
x = module(x, drop_connect)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
result = forward_call(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/efficientnet_pytorch/model.py", line 109, in forward
x = self._depthwise_conv(x)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
result = forward_call(*args, **kwargs)
File "/home/user/.local/lib/python3.8/site-packages/efficientnet_pytorch/utils.py", line 275, in forward
x = F.conv2d(x, self.weight, self.bias, self.stride, self.padding, self.dilation, self.groups)
File "/usr/local/lib/python3.8/dist-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/torch2trt.py", line 310, in wrapper
converter"converter"
File "/usr/local/lib/python3.8/dist-packages/torch2trt-0.4.0-py3.8.egg/torch2trt/converters/conv_functional.py", line 46, in convert_Conv_trt7_functional
layer.stride_nd = stride
TypeError: (): incompatible function arguments. The following argument types are supported:
1. (arg0: tensorrt_bindings.tensorrt.IConvolutionLayer, arg1: tensorrt_bindings.tensorrt.Dims) -> None

Invoked with: <tensorrt_bindings.tensorrt.IConvolutionLayer object at 0x7fee9d995030>, ([1, 1], [1, 1])

Thank you for your assistance in resolving this issue.

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

No branches or pull requests

1 participant