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

TypeError: add_pooling_nd(): incompatible function arguments #867

Open
AlessandroDalponte opened this issue Jun 5, 2023 · 1 comment
Open

Comments

@AlessandroDalponte
Copy link

AlessandroDalponte commented Jun 5, 2023

Hello,

I'm trying to optimize an i3d anomaly detection model, but I'm getting this error:

File "run.py", line 89, in
run_model(args=args)
File "run.py", line 69, in run_model
trt_model = torch2trt(model, input_trt, max_batch_size=args.batch_size)
File "/home/pc01/Desktop/nvidia_torch2trt/torch2trt/torch2trt.py", line 779, in torch2trt
outputs = module(*inputs)
File "/home/pc01/miniforge3/envs/nvidia_rt/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1212, in _call_impl
result = forward_call(*input, **kwargs)
File "/home/pc01/Desktop/nvidia_torch2trt/models/i3d_pytorch.py", line 331, in forward
x = self._modulesend_point # use _modules to work with dataparallel
File "/home/pc01/miniforge3/envs/nvidia_rt/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1212, in _call_impl
result = forward_call(*input, **kwargs)
File "/home/pc01/Desktop/nvidia_torch2trt/models/i3d_pytorch.py", line 45, in forward
return super(MaxPool3dSamePadding, self).forward(x)
File "/home/pc01/miniforge3/envs/nvidia_rt/lib/python3.8/site-packages/torch/nn/modules/pooling.py", line 244, in forward
return F.max_pool3d(input, self.kernel_size, self.stride,
File "/home/pc01/Desktop/nvidia_torch2trt/torch2trt/torch2trt.py", line 310, in wrapper
converter"converter"
File "/home/pc01/Desktop/nvidia_torch2trt/torch2trt/converters/max_pool3d.py", line 33, in convert_max_pool3d
layer = ctx.network.add_pooling_nd(
File "/home/pc01/Desktop/nvidia_torch2trt/torch2trt/torch2trt.py", line 400, in wrapper
ret = attr(*args, **kwargs)
TypeError: add_pooling_nd(): incompatible function arguments. The following argument types are supported:
1. (self: tensorrt.tensorrt.INetworkDefinition, input: tensorrt.tensorrt.ITensor, type: tensorrt.tensorrt.PoolingType, window_size: tensorrt.tensorrt.Dims) -> tensorrt.tensorrt.IPoolingLayer

Invoked with: <tensorrt.tensorrt.INetworkDefinition object at 0x7f1e5ce9ce70>; kwargs: input=<tensorrt.tensorrt.ITensor object at 0x7f1e5cd781b0>, type=<PoolingType.MAX: 0>, window_size=([1, 3, 3], [1, 3, 3], [1, 3, 3])

This is the link to the i3d model I'm using:
https://github.com/piergiaj/pytorch-i3d/blob/master/pytorch_i3d.py

The code in the link above contains classes and methods for creating the network's architecture. I don't know if the "incompatible function arguments" are caused by the way in which the network's architecture is being created, or if it's just the architecture itself, or something else.

To instantiate the model, I'm running:


from models.pytorch_i3d import InceptionI3d
from torch2trt.torch2trt import torch2trt

model = InceptionI3d(400, in_channels=3)
model.load_state_dict(torch.load(weights))
model.train(False)
model.eval().to(device)

input_trt = [torch.ones((batch_size, 3, 16, 224, 224)).cuda()]
trt_model = torch2trt(model, input_trt, max_batch_size=batch_size)


Now I'm only trying with batch_size = 1.
The weights I'm using can be downloaded from this link:
https://github.com/rtvad-ml/i3d-dev/blob/master/models/rgb_imagenet.pt

Thanks in advance.

@xjw00654
Copy link

just change the kernel_size to the (tuple, tuple) format in your model definition. It would work :D

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