NVIDIA-AI-IOT / torch2trt

An easy to use PyTorch to TensorRT converter
MIT License
4.47k stars 669 forks source link

【bug】engine_bytes = state_dict[prefix + "engine"] KeyError: 'engine' #853

Open ulyduts opened 1 year ago

ulyduts commented 1 year ago

When I call the TORCH2TRT module for Yolo series algorithm reasoning, encountered such error, I hope to get the answer.

D:\Anaconda3\envs\python37\lib\site-packages\torch_tensor.py:1013: UserWarning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad attribute won't be populated during autograd.backward(). If you indeed want the .grad field to be populated for a non-leaf Tensor, use .retain_grad() on the non-leaf Tensor. If you access the non-leaf Tensor by mistake, make sure you access the leaf Tensor instead. See github.com/pytorch/pytorch/pull/30531 for more informations. (Triggered internally at aten\src\ATen/core/TensorBody.h:417.) return self._grad Traceback (most recent call last): File "D:\hb\yolov7-tiny-obb-master\predict.py", line 13, in yolo = YOLO() File "D:\hb\yolov7-tiny-obb-master\yolo.py", line 88, in init self.generate() File "D:\hb\yolov7-tiny-obb-master\yolo.py", line 112, in generate model_trt.load_state_dict(torch.load('model_data/yolov7_tiny_backbone_weights.pth')) File "D:\Anaconda3\envs\python37\lib\site-packages\torch\nn\modules\module.py", line 1468, in load_state_dict load(self) File "D:\Anaconda3\envs\python37\lib\site-packages\torch\nn\modules\module.py", line 1463, in load state_dict, prefix, local_metadata, True, missing_keys, unexpected_keys, error_msgs) File "D:\Anaconda3\envs\python37\lib\site-packages\torch2trt-0.4.0-py3.7.egg\torch2trt\torch2trt.py", line 587, in _load_from_state_dict engine_bytes = state_dict[prefix + "engine"] KeyError: 'engine'

Process finished with exit code 1

thank!

aditya-nisal commented 1 week ago

Hello, were you able to resolve his error?