torch2trt icon indicating copy to clipboard operation
torch2trt copied to clipboard

_trt.shape overflow when converting from pytorch to TRT

Open Justin020718 opened this issue 1 year ago • 5 comments

before operator converting, some input tensors had attributes called '_trt' 屏幕截图(240) To deal with it, I've deleted these incorrect '_trt' attributes manually in related converter function in “naive_converters.py”. However, I've encountered sone errors when doing things as follows, and it says:

[05/26/2024-22:35:09] [TRT] [E] 3: context_fusion_net.conv3_up.0:1:CONVOLUTION:GPU: at least 4 dimensions are required for input. [05/26/2024-22:35:09] [TRT] [E] 3: context_fusion_net.conv3_up.0:1:CONVOLUTION:GPU: at least 4 dimensions are required for input. [05/26/2024-22:35:09] [TRT] [E] 4: [network.cpp::nvinfer1::Network::validate::3478] Error Code 4: Internal Error (Layer >context_fusion_net.conv3_up.0:1:CONVOLUTION:GPU failed validation)

Of course, the TRT module was not successfully generated, and when I try to save its state dict, it says:

Traceback (most recent call last): File "E:\DCVC-main\DCVC-DC\quant.py", line 497, in quant_for_p_all torch.save(p_frame_enc_trt.state_dict(), path) File "E:\anaconda3\envs\python3.8\lib\site-packages\torch\nn\modules\module.py", line 1918, in state_dict hook_result = hook(self, destination, prefix, local_metadata) File "E:\anaconda3\envs\python3.8\lib\site-packages\torch2trt-0.5.0-py3.8.egg\torch2trt\trt_module.py", line 60, in _on_state_dict state_dict[prefix + "engine"] = bytearray(self.engine.serialize()) AttributeError: 'NoneType' object has no attribute 'serialize'

Finally, here's my environment: pytorch 2.3.0+cu121 torch2trt 0.5.0 tensorRT 8.6.1.6 (Also tried tensorRT 10.0.1.6, after renaming some covnerting method, I have the same issue)

Since it's my first issue on Github, I really appreciate it if someone could help, or offer some clue to solve it, please!!!!!!!!!!!

Justin020718 avatar May 26 '24 14:05 Justin020718