Open 1wang11lijian1 opened 2 years ago
You might need to update the input shape range in the config, for example:
backend_config = dict(
common_config=dict(max_workspace_size=1 << 30),
model_inputs=[
dict(
input_shapes=dict(
input=dict(
min_shape=[1, 3, 320, 320],
opt_shape=[1, 3, 608, 608],
max_shape=[1, 3, 608, 608])))
])
@grimoire This error also occurs after I use the default model, image and configuration file here
command
python tools/deploy.py `
configs/mmdet/detection/detection_tensorrt-int8_dynamic-160x160-608x608.py `
../mmdetection/configs/yolo/yolov3_d53_mstrain-608_273e_coco.py `
https://download.openmmlab.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-608_273e_coco/yolov3_d53_mstrain-608_273e_coco_20210518_115020-a2c3acb8.pth `
../mmdetection/demo/demo.jpg `
--work-dir ./work-dirs/mmdet/yolo_v3/trt `
--device cuda:0 `
--show `
--dump-info `
detection_tensorrt-int8_dynamic-160x160-608x608.py
contain the following info.
_base_ = [
'../_base_/base_dynamic.py', '../../_base_/backends/tensorrt-int8.py'
]
backend_config = dict(
common_config=dict(max_workspace_size=1 << 30),
model_inputs=[
dict(
input_shapes=dict(
input=dict(
min_shape=[1, 3, 160, 160],
opt_shape=[1, 3, 608, 608],
max_shape=[1, 3, 608, 608])))
])
run out error
(mmdeploy-0.6.0) PS D:\mmd_11.1\mmdeploy> python tools/deploy.py `
>> configs/mmdet/detection/detection_tensorrt-int8_dynamic-160x160-608x608.py `
>> ../mmdetection/configs/yolo/yolov3_d53_mstrain-608_273e_coco.py `
>> https://download.openmmlab.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-608_273e_coco/yolov3_d53_mstrain-608_273e_coco_20210518_115020-a2c3acb8.pth `
>> ../mmdetection/demo/demo.jpg `
>> --work-dir ./work-dirs/mmdet/yolo_v3/trt `
>> --device cuda:0 `
>> --show `
>> --dump-info `
>>
[2022-07-14 19:55:41.848] [mmdeploy] [info] [model.cpp:95] Register 'DirectoryModel'
[2022-07-14 19:55:42.926] [mmdeploy] [info] [model.cpp:95] Register 'DirectoryModel'
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\datasets\utils.py:70: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
'data pipeline in your config file.', UserWarning)
[2022-07-14 19:55:44.588] [mmdeploy] [info] [model.cpp:95] Register 'DirectoryModel'
2022-07-14 19:55:44,592 - mmdeploy - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
load checkpoint from http path: https://download.openmmlab.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-608_273e_coco/yolov3_d53_mstrain-608_273e_coco_20210518_115020-a2c3acb8.pth
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\datasets\utils.py:70: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
'data pipeline in your config file.', UserWarning)
2022-07-14 19:55:46,784 - mmdeploy - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future.
2022-07-14 19:55:46,784 - mmdeploy - INFO - Export PyTorch model to ONNX: ./work-dirs/mmdet/yolo_v3/trt\end2end.onnx.
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdeploy\core\optimizers\function_marker.py:158: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
ys_shape = tuple(int(s) for s in ys.shape)
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\torch\nn\functional.py:3455: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode)
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\models\dense_heads\yolo_head.py:127: UserWarning: DeprecationWarning: `anchor_generator` is deprecated, please use "prior_generator" instead
warnings.warn('DeprecationWarning: `anchor_generator` is deprecated, '
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\core\anchor\anchor_generator.py:333: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors``
warnings.warn('``grid_anchors`` would be deprecated soon. '
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\core\anchor\anchor_generator.py:370: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors``
'``single_level_grid_anchors`` would be deprecated soon. '
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdet\core\bbox\coder\yolo_bbox_coder.py:73: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
assert pred_bboxes.size(-1) == bboxes.size(-1) == 4
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdeploy\pytorch\functions\topk.py:56: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
if k > size:
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdeploy\codebase\mmdet\core\post_processing\bbox_nms.py:259: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
dets, labels = TRTBatchedNMSop.apply(boxes, scores, int(scores.shape[-1]),
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdeploy\mmcv\ops\nms.py:178: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
out_boxes = min(num_boxes, after_topk)
C:\ProgramData\Anaconda3\envs\mmdeploy-0.6.0\lib\site-packages\mmdeploy\mmcv\ops\nms.py:181: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
(batch_size, out_boxes)).to(scores.device))
2022-07-14 19:55:51,902 - mmdeploy - ERROR - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
@grimoire If possible, can you add wechat for details?This is my wechat account 17361712910, thanks.
@grimoire And I found out exactly which line is wrong, but I quit without knowing what the problem is here.
mmdeploy/mmdeploy/apis/onnx/export.py
Line 122 in 14b2bfd
torch.onnx.export()
Among (pytorch1.8.0 ) torch\onnx\utils.py Line 421
if _retain_param_name:
graph_inputs = list(graph.inputs())# Run to this point and exit
@grimoire Could you please help me solve this problem? It is best to test it with the same equipment to see if this problem occurs. Thanks
I can not reproduce the error. Could you print the graph.inputs()
?
@grimoire graph.inputs()
This function does not print out, and exits directly when printing.
This is graph
print result:
graph(%y.1 : Float(1, 3, 416, 608, strides=[758784, 252928, 608, 1], requires_grad=0, device=cuda:0),
%1 : Float(32, 3, 3, 3, strides=[27, 9, 3, 1], requires_grad=1, device=cuda:0),
%2 : Float(32, strides=[1], requires_grad=1, device=cuda:0),
%3 : Float(32, strides=[1], requires_grad=1, device=cuda:0),
%4 : Float(32, strides=[1], requires_grad=0, device=cuda:0),
%5 : Float(32, strides=[1], requires_grad=0, device=cuda:0),
%6 : Long(requires_grad=0, device=cuda:0),
%7 : Float(64, 32, 3, 3, strides=[288, 9, 3, 1], requires_grad=1, device=cuda:0),
%8 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%9 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%10 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%11 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%12 : Long(requires_grad=0, device=cuda:0),
%13 : Float(32, 64, 1, 1, strides=[64, 1, 1, 1], requires_grad=1, device=cuda:0),
%14 : Float(32, strides=[1], requires_grad=1, device=cuda:0),
%15 : Float(32, strides=[1], requires_grad=1, device=cuda:0),
%16 : Float(32, strides=[1], requires_grad=0, device=cuda:0),
%17 : Float(32, strides=[1], requires_grad=0, device=cuda:0),
%18 : Long(requires_grad=0, device=cuda:0),
%19 : Float(64, 32, 3, 3, strides=[288, 9, 3, 1], requires_grad=1, device=cuda:0),
%20 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%21 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%22 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%23 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%24 : Long(requires_grad=0, device=cuda:0),
%25 : Float(128, 64, 3, 3, strides=[576, 9, 3, 1], requires_grad=1, device=cuda:0),
%26 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%27 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%28 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%29 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%30 : Long(requires_grad=0, device=cuda:0),
%31 : Float(64, 128, 1, 1, strides=[128, 1, 1, 1], requires_grad=1, device=cuda:0),
%32 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%33 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%34 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%35 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%36 : Long(requires_grad=0, device=cuda:0),
%37 : Float(128, 64, 3, 3, strides=[576, 9, 3, 1], requires_grad=1, device=cuda:0),
%38 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%39 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%40 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%41 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%42 : Long(requires_grad=0, device=cuda:0),
%43 : Float(64, 128, 1, 1, strides=[128, 1, 1, 1], requires_grad=1, device=cuda:0),
%44 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%45 : Float(64, strides=[1], requires_grad=1, device=cuda:0),
%46 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%47 : Float(64, strides=[1], requires_grad=0, device=cuda:0),
%48 : Long(requires_grad=0, device=cuda:0),
%49 : Float(128, 64, 3, 3, strides=[576, 9, 3, 1], requires_grad=1, device=cuda:0),
%50 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%51 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%52 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%53 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%54 : Long(requires_grad=0, device=cuda:0),
%55 : Float(256, 128, 3, 3, strides=[1152, 9, 3, 1], requires_grad=1, device=cuda:0),
%56 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%57 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%58 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%59 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%60 : Long(requires_grad=0, device=cuda:0),
%61 : Float(128, 256, 1, 1, strides=[256, 1, 1, 1], requires_grad=1, device=cuda:0),
%62 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%63 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%64 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%65 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%66 : Long(requires_grad=0, device=cuda:0),
%67 : Float(256, 128, 3, 3, strides=[1152, 9, 3, 1], requires_grad=1, device=cuda:0),
%68 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%69 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%70 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%71 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%72 : Long(requires_grad=0, device=cuda:0),
%73 : Float(128, 256, 1, 1, strides=[256, 1, 1, 1], requires_grad=1, device=cuda:0),
%74 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%75 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%76 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%77 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%78 : Long(requires_grad=0, device=cuda:0),
%79 : Float(256, 128, 3, 3, strides=[1152, 9, 3, 1], requires_grad=1, device=cuda:0),
%80 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%81 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%82 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%83 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%84 : Long(requires_grad=0, device=cuda:0),
%85 : Float(128, 256, 1, 1, strides=[256, 1, 1, 1], requires_grad=1, device=cuda:0),
%86 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%87 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%88 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%89 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
%90 : Long(requires_grad=0, device=cuda:0),
%91 : Float(256, 128, 3, 3, strides=[1152, 9, 3, 1], requires_grad=1, device=cuda:0),
%92 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%93 : Float(256, strides=[1], requires_grad=1, device=cuda:0),
%94 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%95 : Float(256, strides=[1], requires_grad=0, device=cuda:0),
%96 : Long(requires_grad=0, device=cuda:0),
%97 : Float(128, 256, 1, 1, strides=[256, 1, 1, 1], requires_grad=1, device=cuda:0),
%98 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%99 : Float(128, strides=[1], requires_grad=1, device=cuda:0),
%100 : Float(128, strides=[1], requires_grad=0, device=cuda:0),
@grimoire I just put import onnx
on the first line of mmdeploy/mmdeploy/apis/onnx/export.py, the problem still occurs.
@1wang11lijian1 用不同的deploy cfg去测试,我用这个就可以转换成功。 detection_tensorrt_dynamic-64x64-608x608
graph.inputs() can iterate, but can not convert to list. Can not find the root source. May OpenMMLab team can help us... happened to me with 3070 and windows, most the same with "1wang11lijian1" env.
@1wang11lijian1
Did you do import onnxruntime
before exporting? How about erase it or hide it?
I had the same error and I fixed it by deleting that import statement!
@1wang11lijian1 Did you do
import onnxruntime
before exporting? How about erase it or hide it? I had the same error and I fixed it by deleting that import statement!
把代码开头的import onnxruntime全部搬到函数里面import,亲测有用👍
I converted the mmdeploy model compiled by source code and precompiled package. I encountered this error when converting the model. How can I solve it?
command:
error:
env_info: