cjermain/flink-onnx-pytorch

Could not initialize class ai.onnxruntime.OrtEnvironment??

KangTomwk opened this issue · 1 comments

Hi
I executed ./flink-1.11.1/bin/flink run -c com.datacolin.Job ./flink-onnx-pytorch/target/scala-2.11/flink-onnx-pytorch-assembly-0.0.1.jar appeared as follows error:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class ai.onnxruntime.OrtEnvironment
at com.flink.pytorch.onnx.OrtModel.load(OrtModel.scala:14)
at com.flink.pytorch.onnx.AddFive.open(AddFive.scala:14)
at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:36)
at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:102)
at org.apache.flink.streaming.runtime.tasks.OperatorChain.initializeStateAndOpenOperators(OperatorChain.java:401)
at org.apache.flink.streaming.runtime.tasks.StreamTask.lambda$beforeInvoke$2(StreamTask.java:507)
at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:47)
at org.apache.flink.streaming.runtime.tasks.StreamTask.beforeInvoke(StreamTask.java:501)
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:531)
at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:722)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:547)
at java.base/java.lang.Thread.run(Thread.java:834)
Suppressed: java.lang.NullPointerException
at com.flink.pytorch.onnx.AddFive.close(AddFive.scala:18)
at org.apache.flink.api.common.functions.util.FunctionUtils.closeFunction(FunctionUtils.java:43)
at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.dispose(AbstractUdfStreamOperator.java:117)
at org.apache.flink.streaming.runtime.tasks.StreamTask.disposeAllOperators(StreamTask.java:740)
at org.apache.flink.streaming.runtime.tasks.StreamTask.runAndSuppressThrowable(StreamTask.java:720)
at org.apache.flink.streaming.runtime.tasks.StreamTask.cleanUpInvoke(StreamTask.java:643)
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:552)
... 3 more

It sounds like the ai.onnxruntime.OrtEnvironment class is not found during runtime. It should be packaged in the JAR by sbt. Does your JAR contain it?

Here is what I see when I look for the class in the JAR:

$ jar tf flink-onnx-pytorch-assembly-0.0.1.jar | grep OrtEnvironment.class
ai/onnxruntime/OrtEnvironment.class