Mask2former model torch2onnx error
when I run mmdeploy/tools/deploy.py to convert mask2former pth model to onnx. have some error:
-
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.torch2onnxwith Call id: 0 failed. exit. -
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.
-
success when set static, but infer error: onnxruntime.capi.onnxruntime_pybind11_state.Fail: class
End2EndModelin 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
I meet a same error
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)`
looking 。。。。。
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?