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] ould not export Python function call 'ONNXNMSop' #2360

Closed
3 tasks
lizheng1992 opened this issue Aug 17, 2023 · 3 comments
Closed
3 tasks

[Bug] ould not export Python function call 'ONNXNMSop' #2360

lizheng1992 opened this issue Aug 17, 2023 · 3 comments

Comments

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

使用 openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy1.0.0 这个docker 镜像 转换 RTMIns 模型 到torchscript 报错

oot@d7876f20aa0a:~/workspace/mmdeploy# python3 tools/deploy.py \

    configs/mmdet/instance-seg/instance-seg_torchscript.py  \
   ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco.py \
    ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth   \
    ./checkpoint/demo.jpg \
    --work-dir ../rtmdetins2script \
    --dump-info   

08/17 09:20:19 - 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.
08/17 09:20:19 - 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.
08/17 09:20:21 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2torchscript.torch2torchscript in subprocess
08/17 09:20:22 - 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.
08/17 09:20:22 - 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: ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth
08/17 09:20:22 - mmengine - INFO - Export PyTorch model to torchscript.
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py:3631: 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.
warnings.warn(
/usr/local/lib/python3.8/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
/usr/local/lib/python3.8/dist-packages/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, '
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/anchor_head.py:108: UserWarning: DeprecationWarning: num_anchors is deprecated, for consistency or also use num_base_priors instead
warnings.warn('DeprecationWarning: num_anchors is deprecated, '
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:143: 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)
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:144: 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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/usr/local/lib/python3.8/dist-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
/usr/local/lib/python3.8/dist-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)
/usr/local/lib/python3.8/dist-packages/mmcv/ops/nms.py:30: 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 max_num > 0:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:180: 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 is_use_topk:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:264: 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 num_inst < 1:
08/17 09:20:28 - mmengine - INFO - Save PyTorch model: ../rtmdetins2script/end2end.pt.
Process Process-2:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call
ret = func(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py", line 63, in torch2torchscript
trace(
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in wrap
return self.call_function(func_name
, *args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
return self.call_function_local(func_name, *args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
return pipe_caller(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call
ret = func(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py", line 121, in trace
torch.jit.save(ts_model, output_path)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_serialization.py", line 81, in save
m.save(f, _extra_files=_extra_files)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_script.py", line 686, in save
return self._c.save(str(f), **kwargs)
RuntimeError:
Could not export Python function call 'ONNXNMSop'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to constants:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(156): _nms_with_mask_static
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(102): rtmdet_ins_head__predict_by_feat
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/base_dense_head.py(197): predict
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(24): __forward_impl
/root/workspace/mmdeploy/mmdeploy/core/optimizers/function_marker.py(266): g
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(89): single_stage_detector__forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1090): _slow_forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1102): _call_impl
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(958): trace_module
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(741): trace
/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py(108): trace
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): call
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(275): call_function_local
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(326): call_function
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(356): _wrap
/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py(63): torch2torchscript
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): call
/usr/lib/python3.8/multiprocessing/process.py(108): run
/usr/lib/python3.8/multiprocessing/process.py(315): _bootstrap
/usr/lib/python3.8/multiprocessing/spawn.py(129): _main
/usr/lib/python3.8/multiprocessing/spawn.py(116): spawn_main
(1):

08/17 09:20:28 - mmengine - ERROR - /root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - mmdeploy.apis.pytorch2torchscript.torch2torchscript with Call id: 0 failed. exit.

Reproduction

oot@d7876f20aa0a:~/workspace/mmdeploy# python3 tools/deploy.py \

    configs/mmdet/instance-seg/instance-seg_torchscript.py  \
   ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco.py \
    ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth   \
    ./checkpoint/demo.jpg \
    --work-dir ../rtmdetins2script \
    --dump-info   

08/17 09:20:19 - 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.
08/17 09:20:19 - 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.
08/17 09:20:21 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2torchscript.torch2torchscript in subprocess
08/17 09:20:22 - 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.
08/17 09:20:22 - 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: ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth
08/17 09:20:22 - mmengine - INFO - Export PyTorch model to torchscript.
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py:3631: 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.
warnings.warn(
/usr/local/lib/python3.8/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:2157.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
/usr/local/lib/python3.8/dist-packages/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, '
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/anchor_head.py:108: UserWarning: DeprecationWarning: num_anchors is deprecated, for consistency or also use num_base_priors instead
warnings.warn('DeprecationWarning: num_anchors is deprecated, '
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:143: 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)
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:144: 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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/usr/local/lib/python3.8/dist-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
/usr/local/lib/python3.8/dist-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)
/usr/local/lib/python3.8/dist-packages/mmcv/ops/nms.py:30: 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 max_num > 0:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:180: 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 is_use_topk:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:264: 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 num_inst < 1:
08/17 09:20:28 - mmengine - INFO - Save PyTorch model: ../rtmdetins2script/end2end.pt.
Process Process-2:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call
ret = func(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py", line 63, in torch2torchscript
trace(
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in wrap
return self.call_function(func_name
, *args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
return self.call_function_local(func_name, *args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
return pipe_caller(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call
ret = func(*args, **kwargs)
File "/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py", line 121, in trace
torch.jit.save(ts_model, output_path)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_serialization.py", line 81, in save
m.save(f, _extra_files=_extra_files)
File "/usr/local/lib/python3.8/dist-packages/torch/jit/_script.py", line 686, in save
return self._c.save(str(f), **kwargs)
RuntimeError:
Could not export Python function call 'ONNXNMSop'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to constants:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(156): _nms_with_mask_static
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(102): rtmdet_ins_head__predict_by_feat
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/base_dense_head.py(197): predict
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(24): __forward_impl
/root/workspace/mmdeploy/mmdeploy/core/optimizers/function_marker.py(266): g
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(89): single_stage_detector__forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1090): _slow_forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1102): _call_impl
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(958): trace_module
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(741): trace
/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py(108): trace
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): call
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(275): call_function_local
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(326): call_function
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(356): _wrap
/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py(63): torch2torchscript
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): call
/usr/lib/python3.8/multiprocessing/process.py(108): run
/usr/lib/python3.8/multiprocessing/process.py(315): _bootstrap
/usr/lib/python3.8/multiprocessing/spawn.py(129): _main
/usr/lib/python3.8/multiprocessing/spawn.py(116): spawn_main
(1):

08/17 09:20:28 - mmengine - ERROR - /root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - mmdeploy.apis.pytorch2torchscript.torch2torchscript with Call id: 0 failed. exit.

Environment

oot@d7876f20aa0a:~/workspace/mmdeploy#  python3 tools/deploy.py \
>         configs/mmdet/instance-seg/instance-seg_torchscript.py  \
>        ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco.py \
>         ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth   \
>         ./checkpoint/demo.jpg \
>         --work-dir ../rtmdetins2script \
>         --dump-info   
08/17 09:20:19 - 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.
08/17 09:20:19 - 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.
08/17 09:20:21 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2torchscript.torch2torchscript in subprocess
08/17 09:20:22 - 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.
08/17 09:20:22 - 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: ./checkpoint/rtmdet-ins_tiny_8xb32-300e_coco_20221130_151727-ec670f7e.pth
08/17 09:20:22 - mmengine - INFO - Export PyTorch model to torchscript.
/usr/local/lib/python3.8/dist-packages/torch/nn/functional.py:3631: 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.
  warnings.warn(
/usr/local/lib/python3.8/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
/usr/local/lib/python3.8/dist-packages/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, '
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/anchor_head.py:108: UserWarning: DeprecationWarning: `num_anchors` is deprecated, for consistency or also use `num_base_priors` instead
  warnings.warn('DeprecationWarning: `num_anchors` is deprecated, '
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:143: 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)
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:144: 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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/root/workspace/mmdeploy/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)
/usr/local/lib/python3.8/dist-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
/usr/local/lib/python3.8/dist-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)
/usr/local/lib/python3.8/dist-packages/mmcv/ops/nms.py:30: 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 max_num > 0:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:180: 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 is_use_topk:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py:264: 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 num_inst < 1:
08/17 09:20:28 - mmengine - INFO - Save PyTorch model: ../rtmdetins2script/end2end.pt.
Process Process-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py", line 63, in torch2torchscript
    trace(
  File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 356, in _wrap
    return self.call_function(func_name_, *args, **kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 326, in call_function
    return self.call_function_local(func_name, *args, **kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 275, in call_function_local
    return pipe_caller(*args, **kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in __call__
    ret = func(*args, **kwargs)
  File "/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py", line 121, in trace
    torch.jit.save(ts_model, output_path)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_serialization.py", line 81, in save
    m.save(f, _extra_files=_extra_files)
  File "/usr/local/lib/python3.8/dist-packages/torch/jit/_script.py", line 686, in save
    return self._c.save(str(f), **kwargs)
RuntimeError: 
Could not export Python function call 'ONNXNMSop'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__:
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(156): _nms_with_mask_static
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/dense_heads/rtmdet_ins_head.py(102): rtmdet_ins_head__predict_by_feat
/usr/local/lib/python3.8/dist-packages/mmdet/models/dense_heads/base_dense_head.py(197): predict
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(24): __forward_impl
/root/workspace/mmdeploy/mmdeploy/core/optimizers/function_marker.py(266): g
/root/workspace/mmdeploy/mmdeploy/codebase/mmdet/models/detectors/single_stage.py(89): single_stage_detector__forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1090): _slow_forward
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py(1102): _call_impl
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(958): trace_module
/usr/local/lib/python3.8/dist-packages/torch/jit/_trace.py(741): trace
/root/workspace/mmdeploy/mmdeploy/apis/torch_jit/trace.py(108): trace
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): __call__
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(275): call_function_local
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(326): call_function
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(356): _wrap
/root/workspace/mmdeploy/mmdeploy/apis/pytorch2torchscript.py(63): torch2torchscript
/root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py(107): __call__
/usr/lib/python3.8/multiprocessing/process.py(108): run
/usr/lib/python3.8/multiprocessing/process.py(315): _bootstrap
/usr/lib/python3.8/multiprocessing/spawn.py(129): _main
/usr/lib/python3.8/multiprocessing/spawn.py(116): spawn_main
<string>(1): <module>

08/17 09:20:28 - mmengine - ERROR - /root/workspace/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - `mmdeploy.apis.pytorch2torchscript.torch2torchscript` with Call id: 0 failed. exit.

Error traceback

No response

@RunningLeon
Copy link
Collaborator

@lizheng1992 hi, could you try this PR? #2343

@github-actions
Copy link

This issue is marked as stale because it has been marked as invalid or awaiting response for 7 days without any further response. It will be closed in 5 days if the stale label is not removed or if there is no further response.

@github-actions github-actions bot added the Stale label Aug 29, 2023
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

This issue is closed because it has been stale for 5 days. Please open a new issue if you have similar issues or you have any new updates now.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants