NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.56k stars 673 forks source link

TensorRT] ERROR: (Unnamed Layer* 295) [Concatenation]: all concat input tensors must have the same number of dimensions, but mismatch at input 1. Input 0 shape: [1,1,160,160], Input 1 shape: [1,160,160] #241

Closed Edwardmark closed 4 years ago

Edwardmark commented 4 years ago

python3 inference.py Warning: Encountered known unsupported method torch.unsqueeze [TensorRT] ERROR: (Unnamed Layer 295) [Concatenation]: all concat input tensors must have the same number of dimensions, but mismatch at input 1. Input 0 shape: [1,1,160,160], Input 1 shape: [1,160,160] Traceback (most recent call last): File "inference.py", line 286, in main(parse_arguments(sys.argv[1:])) File "inference.py", line 267, in main handler = DetectorHandler(args) File "inference.py", line 70, in init self.net = torch2trt(self.net, [images_val.cuda()]) File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 377, in torch2trt outputs = module(inputs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 541, in call result = self.forward(*input, **kwargs) File "/app/src/pyramid_v1d.py", line 252, in forward conf.append(torch.cat([max_conf,pos_conf],1).permute(0,2,3,1).contiguous()) File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 202, in wrapper converter'converter' File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/permute.py", line 8, in convert_permute inputtrt = trt(ctx.network, input) File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 116, in trt_ num_dim = len(t._trt.shape) # non-leaf tensors must already have _trt, get shape from that ValueError: len() should return >= 0

I use pdb to debug, but the shape is same not as the error message said, why is that? Thanks.

jaybdub commented 4 years ago

Hi Edwardmark,

Thanks for reaching out! Sometimes the error can be due to a nuanced edge case. Do you mind sharing the PyTorch model that you're attempting to convert?

Best, John

kali20gakki commented 4 years ago

I also meet the same error in yolov3. [TensorRT] ERROR: (Unnamed Layer* 203) [Concatenation]: all concat input tensors must have the same number of dimensions, but mismatch at input 1. Input 0 shape: [1,256,26,26], Input 1 shape: [512,26,26]

Edwardmark commented 4 years ago

@jaybdub @kali20gakki I am testing a detection model, when I only convert the backbone withouthe branch layers, it works fine, maybe it is due to some unsupported shape transform operations. Thanks.