autodeployai / ai-serving

Serving AI/ML models in the open standard formats PMML and ONNX with both HTTP (REST API) and gRPC endpoints
Apache License 2.0
148 stars 31 forks source link

上传模型时报错 #8

Closed kingnop closed 2 years ago

kingnop commented 2 years ago

您好,我在使用Minst模型测试时,部署服务报告一下错误: ai.onnxruntime.OrtException: Error code - ORT_NOT_IMPLEMENTED - message: Could not find an implementation for the node Block386:Div(1) at ai.onnxruntime.OrtSession.createSession(Native Method) at ai.onnxruntime.OrtSession.(OrtSession.java:67) at ai.onnxruntime.OrtEnvironment.createSession(OrtEnvironment.java:163) at ai.onnxruntime.OrtEnvironment.createSession(OrtEnvironment.java:148) at ai.autodeploy.serving.deploy.OnnxModel$.load(OnnxModel.scala:351) at ai.autodeploy.serving.deploy.PredictModel$.load(PredictModel.scala:86) at ai.autodeploy.serving.deploy.ModelManager$.$anonfun$deploy$1(ModelManager.scala:75) at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:672) at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:431) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:47) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) 该ONNX模型包含了一个名为Block386的Div节点,请问这是onnx runtime的问题还是模型的问题呢? model-1637544794327.zip

scorebot commented 2 years ago

@kingnop You need to upgrade your onnx model to opset 14 or higher. I can reproduce the error using the Python API of onnx runtime:

import onnxruntime

sess_options = onnxruntime.SessionOptions()
session = onnxruntime.InferenceSession("model-1637544794327.onnx", sess_options)
2021-11-23 11:00:48.901014 [W:onnxruntime:, model.cc:138 Model] ONNX Runtime only *guarantees* support for models stamped with opset version 7 or above for opset domain 'ai.onnx'. Please upgrade your model to opset 7 or higher. For now, this opset 1 model may run depending upon legacy support of some older opset version operators.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.7/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 206, in __init__
    self._create_inference_session(providers, provider_options)
  File "/anaconda3/lib/python3.7/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 231, in _create_inference_session
    sess.initialize_session(providers or [], provider_options or [])
onnxruntime.capi.onnxruntime_pybind11_state.NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for the node Block386:Div(1)

From the Opset doc (https://github.com/microsoft/onnxruntime/blob/master/docs/OperatorKernels.md), the Div operator is supported by OpSet version 14+:

Div | in A:T in B:T out C:T | 14+ | T = tensor(double), tensor(float), tensor(int32), tensor(int64)
kingnop commented 2 years ago

Thank You! You solve my problem.