mmsegmentation icon indicating copy to clipboard operation
mmsegmentation copied to clipboard

Mask2former model torch2onnx error

Open yangjian1218 opened this issue 2 years ago • 4 comments

when I run mmdeploy/tools/deploy.py to convert mask2former pth model to onnx. have some error:

  1. set dynamic,error is : File "/home/jerry/anaconda3/envs/py39/lib/python3.9/site-packages/torch/storage.py", line 103, in clone return type(self)(self.nbytes(), device=self.device).copy_(self) RuntimeError: NYI: Named tensors are not supported with the tracer 05/10 11:53:57 - mmengine - ERROR - /home/jerry/projects/open-mmlab/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - mmdeploy.apis.pytorch2onnx.torch2onnx with Call id: 0 failed. exit.

  2. set static ,have some warning: WARNING: The shape inference of mmdeploy::grid_sampler type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function. WARNING: The shape inference of prim::Constant type is missing, so it may result in wrong shape inference for the exported graph. Please consider adding it in symbolic function.

  3. success when set static, but infer error: onnxruntime.capi.onnxruntime_pybind11_state.Fail: class End2EndModel in mmdeploy/codebase/mmseg/deploy/segmentation_model.py: [ONNXRuntimeError] : 1 : FAIL : Load model from mmdeploy_model/mask2former/end2end.onnx failed:Fatal error: grid_sampler is not a registered function/op

yangjian1218 avatar May 10 '23 04:05 yangjian1218

I meet a same error

TopAImaster avatar Aug 15 '23 02:08 TopAImaster

Same error, here is the workaround.

As told by the moderators on https://github.com/open-mmlab/mmdeploy/issues/2377:

path = "./site-packages/mmdeploy/lib/libmmdeploy_onnxruntime_ops.so" model_path = "end2end-mask2former.onnx" session_options = ort.SessionOptions() session_options.register_custom_ops_library(path) ort_session = ort.InferenceSession(model_path,session_options)`

hasanirtiza avatar Aug 25 '23 22:08 hasanirtiza

looking 。。。。。

shiyongde avatar Mar 05 '24 13:03 shiyongde

Same error, here is the workaround.

As told by the moderators on open-mmlab/mmdeploy#2377:

path = "./site-packages/mmdeploy/lib/libmmdeploy_onnxruntime_ops.so" model_path = "end2end-mask2former.onnx" session_options = ort.SessionOptions() session_options.register_custom_ops_library(path) ort_session = ort.InferenceSession(model_path,session_options)`

how to fix in windows?

Atumyugi avatar Apr 28 '24 08:04 Atumyugi