NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.58k stars 675 forks source link

ERROR : num_dim = len(t._trt.shape) #303

Closed bigsum71 closed 2 years ago

bigsum71 commented 4 years ago

I have an error related to "len(t._trt.shape)". My network has "torch.max()" and this "torch.max()" has conversion error. Through the debugging I found "t._trt" attribute had shape 0 and so "len(t.trt.shape)" might have that error. If you know the solution, please let me know. Thank you!

========================================================== def forward(self, x): x = self.filter(x) out = torch.split(x, self.out_channels, 1)

    return torch.max(out[0], out[1])  # <== ERROR

=========================================================

File "/usr/local/lib/python2.7/dist-packages/torch2trt/torch2trt.py", line 202, in wrapper converter['converter'](ctx) File "/usr/local/lib/python2.7/dist-packages/torch2trt/converters/max.py", line 30, in convert_max __convert_max_elementwise(ctx) File "/usr/local/lib/python2.7/dist-packages/torch2trt/converters/max.py", line 9, in __convert_max_elementwise input_a_trt, input_b_trt = trt_(ctx.network, input_a, input_b) File "/usr/local/lib/python2.7/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 ==========================================================
AtsunoriFujita commented 4 years ago

I have same problem. How can I solve this?

[TensorRT] ERROR: (Unnamed Layer* 72) [Slice]: mismatch in number of dimensions for start. Traceback (most recent call last): File "convert.py", line 716, in <module> model_trt = torch2trt(model, [x]) 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 532, in __call__ result = self.forward(*input, **kwargs) File "convert.py", line 407, in forward max_conf, _ = torch.max(conf_x[:, 0:3, :, :], dim=1, keepdim=False) File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 202, in wrapper converter['converter'](ctx) File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/max.py", line 32, in convert_max __convert_max_reduce(ctx) File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/max.py", line 19, in __convert_max_reduce input_trt= 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

bitwangdan commented 4 years ago

I have same problem. How can I solve this?

[TensorRT] ERROR: (Unnamed Layer* 72) [Slice]: mismatch in number of dimensions for start. Traceback (most recent call last): File "convert.py", line 716, in <module> model_trt = torch2trt(model, [x]) 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 532, in __call__ result = self.forward(*input, **kwargs) File "convert.py", line 407, in forward max_conf, _ = torch.max(conf_x[:, 0:3, :, :], dim=1, keepdim=False) File "/usr/local/lib/python3.6/dist-packages/torch2trt/torch2trt.py", line 202, in wrapper converter['converter'](ctx) File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/max.py", line 32, in convert_max __convert_max_reduce(ctx) File "/usr/local/lib/python3.6/dist-packages/torch2trt/converters/max.py", line 19, in __convert_max_reduce input_trt= 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

me too!Have you solved the problem yet?

AtsunoriFujita commented 4 years ago

I converted to TRT just before the error. The conversion was successful, but the output was very different from before the conversion. I dealt with pytorch → onnx → tensorrt.

bigsum71 commented 2 years ago

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.

        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2022-07-19T06:02:44

        * 메일 제목 : 

Re: [NVIDIA-AI-IOT/torch2trt] ERROR : num_dim = len(t._trt.shape) (#303)

            * 실패 사유 : 

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.

    © Dooray!.
farzanehnakhaee70 commented 10 months ago

Can anyone solve this issue?

bigsum71 commented 10 months ago

Dooray! 메일 발송 실패 안내

메일 발송 실패 안내

@.***) 님께 보낸 메일이 전송되지 못하였습니다.

      실패 사유를 확인해보세요.

        * 받는 사람 : 

@.***)

        * 발송 시간 : 

2023-12-04T18:22:10

        * 메일 제목 : 

Re: [NVIDIA-AI-IOT/torch2trt] ERROR : num_dim = len(t._trt.shape) (#303)

            * 실패 사유 : 

받는 사람이 회원님의 메일을 수신차단 하였습니다.

      이 메일은 발신전용으로 회신되지 않습니다.
      더 궁금하신 사항은
      ***@***.***
      으로 문의해 주시기 바랍니다.

    © Dooray!.