You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I am trying to convert my model from torch to tensorrt using two-step convertion which converts the model to onnx first. The convertion to onnx is ok, but the convertion from onnx to tensorrt fails. My environment is Win10, pytorch1.11.0, mmdeploy0.9.0, onnx1.8.1. The following is my command.
from mmdeploy.apis import torch2onnx
from mmdeploy.apis.tensorrt import onnx2tensorrt
from mmdeploy.backend.sdk.export_info import export2SDK
import os
img = 'D:\Programs\...\mmdetection\demo/demo.png'
work_dir = 'D:\Programs\...\mmdeploy\work_dirs_maskrcnn'
save_file = 'end2end.onnx'
deploy_cfg = 'D:\Programs\...\mmdeploy\configs\mmdet\instance-seg/instance-seg_onnxruntime_static.py'
model_cfg = 'D:/Programs/.../mmdetection/configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py'
model_checkpoint = 'D:/Programs/.../mmdetection/work_dirs_maskrcnn4/epoch_1983.pth '
device = 'cpu'
# 1. convert model to IR(onnx)
torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg,
model_checkpoint, device)
# 2. convert IR to tensorrt
onnx_model = os.path.join(work_dir, save_file)
save_file = 'end2end.engine'
deploy_cfg = 'D:\Programs\...\mmdeploy\configs\mmdet\instance-seg/instance-seg_tensorrt_static-800x1344.py'
model_id = 0
device = 'cuda'
onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)
# 3. extract pipeline info for sdk use (dump-info)
export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint, device=device)
The following is the error messages.
.............
2022-11-09 10:25:28,921 - mmdeploy - INFO - Execute onnx optimize passes.
2022-11-09 10:25:29,632 - mmdeploy - WARNING - Could not load the library of tensorrt plugins. Because the file does not exist:
[11/09/2022-10:25:29] [TRT] [I] [MemUsageChange] Init CUDA: CPU +353, GPU +0, now: CPU 8798, GPU 1187 (MiB)
[11/09/2022-10:25:30] [TRT] [I] [MemUsageChange] Init builder kernel library: CPU +339, GPU +104, now: CPU 9325, GPU 1291 (MiB)
[11/09/2022-10:25:31] [TRT] [W] onnx2trt_utils.cpp:369: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
Traceback (most recent call last):
File "D:/Programs/.../mmdetection/torch2tensorrt.py", line 24, in <module>
onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)
File "d:\programs\...\mmdeploy\mmdeploy\apis\core\pipeline_manager.py", line 356, in _wrap
return self.call_function(func_name_, *args, **kwargs)
File "d:\programs\...\mmdeploy\mmdeploy\apis\core\pipeline_manager.py", line 326, in call_function
return self.call_function_local(func_name, *args, **kwargs)
File "d:\programs\...\mmdeploy\mmdeploy\apis\core\pipeline_manager.py", line 275, in call_function_local
return pipe_caller(*args, **kwargs)
File "d:\programs\...\mmdeploy\mmdeploy\apis\core\pipeline_manager.py", line 107, in __call__
ret = func(*args, **kwargs)
File "d:\programs\...\mmdeploy\mmdeploy\backend\tensorrt\onnx2tensorrt.py", line 88, in onnx2tensorrt
device_id=device_id)
File "d:\programs\...\mmdeploy\mmdeploy\backend\tensorrt\utils.py", line 165, in from_onnx
raise RuntimeError(f'Failed to parse onnx, {error_msgs}')
RuntimeError: Failed to parse onnx, In node 12 (parseGraph): INVALID_NODE: Invalid Node - Pad_12
[shuffleNode.cpp::nvinfer1::builder::ShuffleNode::symbolicExecute::392] Error Code 4: Internal Error (Reshape_4: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
[11/09/2022-10:25:31] [TRT] [W] onnx2trt_utils.cpp:395: One or more weights outside the range of INT32 was clamped
[11/09/2022-10:25:31] [TRT] [E] [shuffleNode.cpp::nvinfer1::builder::ShuffleNode::symbolicExecute::392] Error Code 4: Internal Error (Reshape_4: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
Process finished with exit code 1
What is the cause of the problem? How can I fix this? Thank you in advance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi. I am trying to convert my model from torch to tensorrt using two-step convertion which converts the model to onnx first. The convertion to onnx is ok, but the convertion from onnx to tensorrt fails. My environment is Win10, pytorch1.11.0, mmdeploy0.9.0, onnx1.8.1. The following is my command.
The following is the error messages.
What is the cause of the problem? How can I fix this? Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions