NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.62k stars 677 forks source link

Warning: Encountered known unsupported method torch.Tensor.new_zeros #781

Open Surtr07 opened 2 years ago

Surtr07 commented 2 years ago

I try to convert my model but meet this problem, is there any solution? Warning: Encountered known unsupported method torch.Tensor.new_zeros [08/02/2022-09:12:28] [TRT] [E] 9: [graphShapeAnalyzer.cpp::addVolumeCheck::604] Error Code 9: Internal Error ((Unnamed Layer* 313) [Slice]_output: dimension 3 never exceeds -1) t.shape = (0) [08/02/2022-09:12:28] [TRT] [E] 9: [graphShapeAnalyzer.cpp::addVolumeCheck::604] Error Code 9: Internal Error ((Unnamed Layer* 313) [Slice]_output: dimension 3 never exceeds -1) Traceback (most recent call last): File "aanet2trt.py", line 184, in <module> model_trt_int8 = torch2trt(net.eval(), (input_data,input_data), max_batch_size=1, fp16_mode=True) File "/home/nvidia/torch2trt-master/torch2trt/torch2trt.py", line 745, in torch2trt outputs = module(*inputs) File "/home/nvidia/miniconda3/envs/yolov5env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1129, in _call_impl result = forward_call(*input, **kwargs) File "/home/nvidia/torch2trt-master/nets/aanet.py", line 209, in forward cost_volume = self.cost_volume_construction(left_feature, right_feature) File "/home/nvidia/torch2trt-master/nets/aanet.py", line 140, in cost_volume_construction cost_volume = self.cost_volume(left_feature, right_feature) File "/home/nvidia/miniconda3/envs/yolov5env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1129, in _call_impl result = forward_call(*input, **kwargs) File "/home/nvidia/torch2trt-master/nets/cost.py", line 73, in forward cost_volume = cost_volume_module(left_feature_pyramid[s], File "/home/nvidia/miniconda3/envs/yolov5env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1111, in _call_impl return forward_call(*input, **kwargs) File "/home/nvidia/torch2trt-master/nets/cost.py", line 48, in forward cost_volume[:, i, :, i:] = (left_feature[:, :, :, i:] * right_feature[:, :, :, :-i]).mean(dim=1) File "/home/nvidia/torch2trt-master/torch2trt/torch2trt.py", line 316, in wrapper converter["converter"](ctx) File "/home/nvidia/torch2trt-master/torch2trt/converters/mul.py", line 15, in convert_mul input_a_trt, input_b_trt = broadcast_trt_tensors(ctx.network, [input_a_trt, input_b_trt], len(output.shape)) File "/home/nvidia/torch2trt-master/torch2trt/torch2trt.py", line 199, in broadcast_trt_tensors print(len(t.shape)) ValueError: __len__() should return >= 0

18871271658 commented 1 year ago

same problem, have you solve that?