open-mmlab / mmdeploy

OpenMMLab Model Deployment Framework
https://mmdeploy.readthedocs.io/en/latest/
Apache License 2.0
2.74k stars 628 forks source link

torch2onnx failed for YOLOv3 on Windows #746

Open 1wang11lijian1 opened 2 years ago

1wang11lijian1 commented 2 years ago

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:

(mmdeploy_11.1) PS D:\mmd_11.1\mmdeploy\build\install\example\build> python D:/mmd_11.1/mmdeploy/tools/deploy.py `
>>     D:/mmd_11.1/mmdeploy/configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py `
>>     D:/mmd模型转换/file_lunzhou/yolov3_d53_mstrain-608_273e_coco.py `
>>     D:/mmd模型转换/file_lunzhou/epoch_271.pth `
>>     D:/mmd模型转换/Image_20220701185830629_01.jpg `
>>     --work-dir D:/mmd模型转换/work_dir_lunzhou `
>>     --device cuda:0 `
>>     --show `
>>     --dump-info

error:

C:\ProgramData\Anaconda3\envs\mmdeploy_11.1\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-12 20:17:06,949 - mmdeploy - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
load checkpoint from local path: D:/mmd模型转换/file_lunzhou/epoch_271.pth
C:\ProgramData\Anaconda3\envs\mmdeploy_11.1\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-12 20:17:11,640 - mmdeploy - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future.
2022-07-12 20:17:11,641 - mmdeploy - INFO - Export PyTorch model to ONNX: D:/mmd模型转换/work_dir_lunzhou\end2end.onnx.
d:\mmd_11.1\mmdeploy\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_11.1\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_11.1\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_11.1\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_11.1\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_11.1\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
d:\mmd_11.1\mmdeploy\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:
d:\mmd_11.1\mmdeploy\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]),
d:\mmd_11.1\mmdeploy\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)
d:\mmd_11.1\mmdeploy\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-12 20:17:14,986 - mmdeploy - ERROR - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.

env_info:

2022-07-12 20:19:14,387 - mmdeploy - INFO - 

2022-07-12 20:19:14,387 - mmdeploy - INFO - **********Environmental information**********
'gcc' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���
fatal: unsafe repository ('D:/mmd_11.1/mmdeploy' is owned by someone else)
To add an exception for this directory, call:

    git config --global --add safe.directory D:/mmd_11.1/mmdeploy

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run
again for more information.
2022-07-12 20:19:15,276 - mmdeploy - INFO - sys.platform: win32
2022-07-12 20:19:15,276 - mmdeploy - INFO - Python: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:35:01) [MSC v.1916 64 bit (AMD64)]
2022-07-12 20:19:15,276 - mmdeploy - INFO - CUDA available: True
2022-07-12 20:19:15,276 - mmdeploy - INFO - GPU 0: NVIDIA GeForce RTX 3060
2022-07-12 20:19:15,276 - mmdeploy - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1
2022-07-12 20:19:15,276 - mmdeploy - INFO - NVCC: Build cuda_11.1.relgpu_drvr455TC455_06.29190527_0
2022-07-12 20:19:15,276 - mmdeploy - INFO - GCC: n/a
2022-07-12 20:19:15,276 - mmdeploy - INFO - PyTorch: 1.8.0
2022-07-12 20:19:15,276 - mmdeploy - INFO - PyTorch compiling details: PyTorch built with:
  - C++ Version: 199711
  - MSVC 192829337
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191125 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v1.7.0 (Git Hash 7aed236906b1f7a05c0917e5257a1af05e9ff683)
  - OpenMP 2019
  - CPU capability usage: AVX2
  - CUDA Runtime 11.1
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
  - CuDNN 8.0.5
  - Magma 2.5.4
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.1, CUDNN_VERSION=8.0.5, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /w /bigobj -DUSE_PTHREADPOOL -openmp:experimental -DNDEBUG -DUSE_FBGEMM -DUSE_XNNPACK, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.8.0, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, 

2022-07-12 20:19:15,276 - mmdeploy - INFO - TorchVision: 0.9.0
2022-07-12 20:19:15,276 - mmdeploy - INFO - OpenCV: 4.6.0
2022-07-12 20:19:15,276 - mmdeploy - INFO - MMCV: 1.4.0
2022-07-12 20:19:15,276 - mmdeploy - INFO - MMCV Compiler: MSVC 192930137
2022-07-12 20:19:15,276 - mmdeploy - INFO - MMCV CUDA Compiler: 11.1
2022-07-12 20:19:15,276 - mmdeploy - INFO - MMDeploy: 0.6.0+
2022-07-12 20:19:15,276 - mmdeploy - INFO - 

2022-07-12 20:19:15,276 - mmdeploy - INFO - **********Backend information**********
2022-07-12 20:19:15,635 - mmdeploy - INFO - onnxruntime: None   ops_is_avaliable : False
2022-07-12 20:19:15,657 - mmdeploy - INFO - tensorrt: 8.2.1.8   ops_is_avaliable : True
2022-07-12 20:19:15,679 - mmdeploy - INFO - ncnn: None  ops_is_avaliable : False
2022-07-12 20:19:15,680 - mmdeploy - INFO - pplnn_is_avaliable: False
2022-07-12 20:19:15,682 - mmdeploy - INFO - openvino_is_avaliable: False
2022-07-12 20:19:15,682 - mmdeploy - INFO - 

2022-07-12 20:19:15,682 - mmdeploy - INFO - **********Codebase information**********
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmdet:  2.25.0
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmseg:  None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmcls:  None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmocr:  None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmedit: None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmdet3d:    None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmpose: None
2022-07-12 20:19:15,683 - mmdeploy - INFO - mmrotate:   None

Process finished with exit code 0
grimoire commented 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])))
  ])
1wang11lijian1 commented 2 years ago

@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.
1wang11lijian1 commented 2 years ago

@grimoire If possible, can you add wechat for details?This is my wechat account 17361712910, thanks.

1wang11lijian1 commented 2 years ago

@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
1wang11lijian1 commented 2 years ago

@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

grimoire commented 2 years ago

I can not reproduce the error. Could you print the graph.inputs()?

1wang11lijian1 commented 2 years ago

@grimoire graph.inputs()This function does not print out, and exits directly when printing.

grimoire commented 2 years ago

https://github.com/onnx/onnx/issues/3493 Try import onnx at the first line in https://github.com/open-mmlab/mmdeploy/blob/14b2bfd524d197565621fedbc47b5940bb22ceed/mmdeploy/apis/onnx/export.py#L122

1wang11lijian1 commented 2 years ago

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),
1wang11lijian1 commented 2 years ago

@grimoire I just put import onnx on the first line of mmdeploy/mmdeploy/apis/onnx/export.py, the problem still occurs.

roxroxroxrox commented 2 years ago

@1wang11lijian1 用不同的deploy cfg去测试,我用这个就可以转换成功。 detection_tensorrt_dynamic-64x64-608x608

shuxp commented 1 year ago

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.

vision-gtc commented 5 months ago

@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!

wsora commented 4 months ago

@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,亲测有用👍