Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Tried to run the example in the mmdeploy tutorial but failed #2756

Open
3 tasks done
Ochre-amber opened this issue May 5, 2024 · 3 comments
Open
3 tasks done

Comments

@Ochre-amber
Copy link

Checklist

  • I have searched related issues but cannot get the expected help.
  • 2. I have read the FAQ documentation but cannot get the expected help.
  • 3. The bug has not been fixed in the latest version.

Describe the bug

Tried to run the example in the mmdeploy tutorial but failed
https://mmdeploy.readthedocs.io/en/latest/get_started.html)

Reproduction

(tensoryolo) D:\Programs\last\project>python mmdeploy/tools/deploy.py mmdeploy/configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py mmdetection/configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth mmdetection/demo/demo.jpg --work-dir mmdeploy_model/faster-rcnn --device cuda --dump-info

Environment

05/05 09:53:24 - mmengine - INFO -

05/05 09:53:24 - mmengine - INFO - **********Environmental information**********
05/05 09:53:28 - mmengine - INFO - sys.platform: win32
05/05 09:53:28 - mmengine - INFO - Python: 3.8.18 | packaged by conda-forge | (default, Dec 23 2023, 17:17:17) [MSC v.1929 64 bit (AMD64)]
05/05 09:53:28 - mmengine - INFO - CUDA available: True
05/05 09:53:28 - mmengine - INFO - MUSA available: False
05/05 09:53:28 - mmengine - INFO - numpy_random_seed: 2147483648
05/05 09:53:28 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4060 Laptop GPU
05/05 09:53:28 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1
05/05 09:53:28 - mmengine - INFO - NVCC: Cuda compilation tools, release 12.1, V12.1.105
05/05 09:53:28 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.39.33523 版
05/05 09:53:28 - mmengine - INFO - GCC: n/a
05/05 09:53:28 - mmengine - INFO - PyTorch: 2.1.2
05/05 09:53:28 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - C++ Version: 199711
  - MSVC 192930151
  - Intel(R) Math Kernel Library Version 2020.0.2 Product Build 20200624 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v3.1.1 (Git Hash 64f6bcbcbab628e96f33a62c3e975f8535a7bde4)
  - OpenMP 2019
  - LAPACK is enabled (usually provided by MKL)
  - CPU capability usage: AVX2
  - CUDA Runtime 12.1
  - NVCC architecture flags: -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_90,code=sm_90
  - CuDNN 8.8.1  (built against CUDA 12.0)
  - Magma 2.5.4
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.1, CUDNN_VERSION=8.8.1, CXX_COMPILER=C:/cb/pytorch_1000000000000/work/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /GR /EHsc /bigobj /FS -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /utf-8 /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=OFF, TORCH_VERSION=2.1.2, 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, USE_ROCM=OFF,

05/05 09:53:28 - mmengine - INFO - TorchVision: 0.16.2
05/05 09:53:28 - mmengine - INFO - OpenCV: 4.8.1
05/05 09:53:28 - mmengine - INFO - MMEngine: 0.10.4
05/05 09:53:28 - mmengine - INFO - MMCV: 2.1.0
05/05 09:53:28 - mmengine - INFO - MMCV Compiler: MSVC 192930148
05/05 09:53:28 - mmengine - INFO - MMCV CUDA Compiler: 12.1
05/05 09:53:28 - mmengine - INFO - MMDeploy: 1.0.0+bc75c9d
05/05 09:53:28 - mmengine - INFO -

05/05 09:53:28 - mmengine - INFO - **********Backend information**********
05/05 09:53:29 - mmengine - INFO - tensorrt:    8.6.1
05/05 09:53:29 - mmengine - INFO - tensorrt custom ops: Available
05/05 09:53:29 - mmengine - INFO - ONNXRuntime: 1.8.1
05/05 09:53:29 - mmengine - INFO - ONNXRuntime-gpu:     None
05/05 09:53:29 - mmengine - INFO - ONNXRuntime custom ops:      Available
05/05 09:53:29 - mmengine - INFO - pplnn:       None
05/05 09:53:29 - mmengine - INFO - ncnn:        None
05/05 09:53:29 - mmengine - INFO - snpe:        None
05/05 09:53:29 - mmengine - INFO - openvino:    None
05/05 09:53:29 - mmengine - INFO - torchscript: 2.1.2+cu121
05/05 09:53:29 - mmengine - INFO - torchscript custom ops:      NotAvailable
05/05 09:53:29 - mmengine - INFO - rknn-toolkit:        None
05/05 09:53:29 - mmengine - INFO - rknn-toolkit2:       None
05/05 09:53:29 - mmengine - INFO - ascend:      None
05/05 09:53:29 - mmengine - INFO - coreml:      None
05/05 09:53:29 - mmengine - INFO - tvm: None
05/05 09:53:29 - mmengine - INFO - vacc:        None
05/05 09:53:29 - mmengine - INFO -

05/05 09:53:29 - mmengine - INFO - **********Codebase information**********
05/05 09:53:29 - mmengine - INFO - mmdet:       3.3.0
05/05 09:53:29 - mmengine - INFO - mmseg:       None
05/05 09:53:29 - mmengine - INFO - mmcls:       None
05/05 09:53:29 - mmengine - INFO - mmocr:       None
05/05 09:53:29 - mmengine - INFO - mmedit:      None
05/05 09:53:29 - mmengine - INFO - mmdet3d:     None
05/05 09:53:29 - mmengine - INFO - mmpose:      None
05/05 09:53:29 - mmengine - INFO - mmrotate:    None
05/05 09:53:29 - mmengine - INFO - mmaction:    None
05/05 09:53:29 - mmengine - INFO - mmrazor:     None

Error traceback

05/05 09:49:18 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
05/05 09:49:18 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "mmdet_tasks" registry tree. As a workaround, the current "mmdet_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
05/05 09:49:20 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
05/05 09:49:21 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
05/05 09:49:21 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "mmdet_tasks" registry tree. As a workaround, the current "mmdet_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
Loads checkpoint by local backend from path: checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
05/05 09:49:24 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future.
05/05 09:49:24 - mmengine - INFO - Export PyTorch model to ONNX: mmdeploy_model/faster-rcnn\end2end.onnx.
05/05 09:49:24 - mmengine - WARNING - Can not find torch.nn.functional._scaled_dot_product_attention, function rewrite will not be applied
05/05 09:49:24 - mmengine - WARNING - Can not find mmdet.models.utils.transformer.PatchMerging.forward, function rewrite will not be applied
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\core\optimizers\function_marker.py:160: 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)
d:\programs\last\project\mmdetection\mmdet\models\dense_heads\anchor_head.py:115: UserWarning: DeprecationWarning: anchor_generator is deprecated, please use "prior_generator" instead
  warnings.warn('DeprecationWarning: anchor_generator is deprecated, '
d:\programs\last\project\mmdetection\mmdet\models\task_modules\prior_generators\anchor_generator.py:356: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors``
  warnings.warn('``grid_anchors`` would be deprecated soon. '
d:\programs\last\project\mmdetection\mmdet\models\task_modules\prior_generators\anchor_generator.py:392: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors``
  warnings.warn(
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\dense_heads\rpn_head.py:89: 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 cls_score.size()[-2:] == bbox_pred.size()[-2:]
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\pytorch\functions\topk.py:58: 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:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\task_modules\coders\delta_xywh_bbox_coder.py:38: 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(0) == bboxes.size(0)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\task_modules\coders\delta_xywh_bbox_coder.py:40: 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)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\deploy\utils.py:95: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
  assert len(max_shape) == 2, '`max_shape` should be [h, w]'
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:451: 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!
  int(scores.shape[-1]),
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:148: 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:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\roi_heads\standard_roi_head.py:41: 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!
  rois_dims = int(rois.shape[-1])
05/05 09:49:44 - mmengine - ERROR - D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\apis\core\pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2onnx.torch2onnx` with Call id: 0 failed. exit.
@Ochre-amber
Copy link
Author

Ochre-amber commented May 5, 2024

I also tried to run the example from the mmdetection tutorial, but the same run failed.
(https://mmdetection.readthedocs.io/zh-cn/v3.0.0/user_guides/deploy.html)

from mmdeploy.apis import torch2onnx
from mmdeploy.backend.sdk.export_info import export2SDK

img = 'demo/demo.jpg'
work_dir = 'mmdeploy_models/mmdet/onnx'
save_file = 'end2end.onnx'
deploy_cfg = '../mmdeploy/configs/mmdet/detection/detection_onnxruntime_dynamic.py'
model_cfg = 'configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py'
model_checkpoint = 'faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cpu'

# 1. convert model to onnx
torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg,
           model_checkpoint, device)

# 2. extract pipeline info for inference by MMDeploy SDK
export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint,
           device=device)
D:\Coding\anaconda\envs\tensoryolo\python.exe D:\Programs\last\project\mmdetection\to_onnx.py 
05/05 11:13:23 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
05/05 11:13:23 - mmengine - WARNING - Failed to search registry with scope "mmdet" in the "mmdet_tasks" registry tree. As a workaround, the current "mmdet_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmdet" is a correct scope, or whether the registry is initialized.
Loads checkpoint by local backend from path: faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
05/05 11:13:23 - mmengine - WARNING - DeprecationWarning: get_onnx_config will be deprecated in the future. 
05/05 11:13:23 - mmengine - INFO - Export PyTorch model to ONNX: mmdeploy_models/mmdet/onnx\end2end.onnx.
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\core\optimizers\function_marker.py:160: 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)
D:\Programs\last\project\mmdetection\mmdet\models\dense_heads\anchor_head.py:115: UserWarning: DeprecationWarning: anchor_generator is deprecated, please use "prior_generator" instead
  warnings.warn('DeprecationWarning: anchor_generator is deprecated, '
D:\Programs\last\project\mmdetection\mmdet\models\task_modules\prior_generators\anchor_generator.py:356: UserWarning: ``grid_anchors`` would be deprecated soon. Please use ``grid_priors`` 
  warnings.warn('``grid_anchors`` would be deprecated soon. '
D:\Programs\last\project\mmdetection\mmdet\models\task_modules\prior_generators\anchor_generator.py:392: UserWarning: ``single_level_grid_anchors`` would be deprecated soon. Please use ``single_level_grid_priors`` 
  warnings.warn(
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\dense_heads\rpn_head.py:89: 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 cls_score.size()[-2:] == bbox_pred.size()[-2:]
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\pytorch\functions\topk.py:28: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  k = torch.tensor(k, device=input.device, dtype=torch.long)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\task_modules\coders\delta_xywh_bbox_coder.py:38: 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(0) == bboxes.size(0)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\task_modules\coders\delta_xywh_bbox_coder.py:40: 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)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\deploy\utils.py:48: TracerWarning: Using len to get tensor shape might cause the trace to be incorrect. Recommended usage would be tensor.shape[0]. Passing a tensor of different shape might lead to errors or silently give incorrect results.
  assert len(max_shape) == 2, '`max_shape` should be [h, w]'
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:270: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  iou_threshold = torch.tensor([iou_threshold], dtype=torch.float32)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:271: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  score_threshold = torch.tensor([score_threshold], dtype=torch.float32)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:44: TracerWarning: Converting a tensor to a Python float 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!
  score_threshold = float(score_threshold)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\mmcv\ops\nms.py:45: TracerWarning: Converting a tensor to a Python float 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!
  iou_threshold = float(iou_threshold)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmcv\ops\nms.py:123: 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 boxes.size(1) == 4
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmcv\ops\nms.py:124: 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 boxes.size(0) == scores.size(0)
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmdeploy\codebase\mmdet\models\roi_heads\standard_roi_head.py:41: 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!
  rois_dims = int(rois.shape[-1])
D:\Coding\anaconda\envs\tensoryolo\lib\site-packages\mmcv\ops\roi_align.py:78: 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 rois.size(1) == 5, 'RoI must be (idx, x1, y1, x2, y2)!'

Process finished with exit code -1073741819 (0xC0000005)

@fat-921
Copy link

fat-921 commented May 8, 2024

请问你解决了吗?我的环境跟你一样,也遇到了这个问题。。

@Ochre-amber
Copy link
Author

Ochre-amber commented May 8, 2024

@fat-921 我还没有解决,尝试修改环境配置,但还没有找到问题的原因。事实上,我当前版本中所有模型的转换都没有成功。

@Ochre-amber Ochre-amber changed the title [Bug] [Bug] Tried to run the example in the mmdeploy tutorial but failed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants