Closed iszhangsc closed 2 years ago
OnnxRuntime will try to extract shared library into temp directory at runtime. Looks like it failed, can you check the following:
You can also try to redirect the cache directory by setting system property to your own cache folder which is writable: `System.setProperty("onnxruntime.native.path", "/my_cache");
OnnxRuntime will try to extract shared library into temp directory at runtime. Looks like it failed, can you check the following:
- Check System.getProperty("java.io.tmpdir"), and see if it point to a valid path
- check the temp path is writable
You can also try to redirect the cache directory by setting system property to your own cache folder which is writable: `System.setProperty("onnxruntime.native.path", "/my_cache");
I tried using System.setProperty("onnxruntime.native.path", "/Users/zhangshichang/.djl.ai/my_cache")
。
However :
Caused by: java.lang.RuntimeException: Failed to load onnx-runtime library
at ai.onnxruntime.OrtEnvironment.
Try add these dependencies in your pom.xml:
<dependency>
<groupId>ai.djl.onnxruntime</groupId>
<artifactId>onnxruntime-engine</artifactId>
<exclusions>
<exclusion>
<groupId>com.microsoft.onnxruntime</groupId>
<artifactId>onnxruntime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.microsoft.onnxruntime</groupId>
<artifactId>onnxruntime</artifactId>
<version>1.12.1</version>
<scope>runtime</scope>
</dependency>
ai.onnxruntime.OnnxRuntime
classpom.xml
file, your pom.xml is using CPU (I guess you try to use gpu), but the log showing you are using GPU jar file.thank! The onnxruntime of the gpu version I used earlier
Description
Caused by: java.lang.UnsatisfiedLinkError: no onnxruntime in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) ~[na:1.8.0_181] at java.lang.Runtime.loadLibrary0(Runtime.java:870) ~[na:1.8.0_181] at java.lang.System.loadLibrary(System.java:1122) ~[na:1.8.0_181] at ai.onnxruntime.OnnxRuntime.load(OnnxRuntime.java:338) ~[onnxruntime_gpu-1.12.1.jar:1.12.1] at ai.onnxruntime.OnnxRuntime.init(OnnxRuntime.java:139) ~[onnxruntime_gpu-1.12.1.jar:1.12.1] at ai.onnxruntime.OrtEnvironment.(OrtEnvironment.java:29) ~[onnxruntime_gpu-1.12.1.jar:1.12.1]
at ai.djl.onnxruntime.engine.OrtEngine.(OrtEngine.java:45) ~[onnxruntime-engine-0.15.0.jar:na]
at ai.djl.onnxruntime.engine.OrtEngine.newInstance(OrtEngine.java:49) ~[onnxruntime-engine-0.15.0.jar:na]
at ai.djl.onnxruntime.engine.OrtEngineProvider.getEngine(OrtEngineProvider.java:40) ~[onnxruntime-engine-0.15.0.jar:na]
at ai.djl.engine.Engine.getEngine(Engine.java:177) ~[api-0.15.0.jar:na]
at ai.djl.Model.newInstance(Model.java:98) ~[api-0.15.0.jar:na]
at ai.djl.repository.zoo.BaseModelLoader.createModel(BaseModelLoader.java:187) ~[api-0.15.0.jar:na]
at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:149) ~[api-0.15.0.jar:na]
at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:166) ~[api-0.15.0.jar:na]
at ai.djl.repository.zoo.ModelZoo.loadModel(ModelZoo.java:132) ~[api-0.15.0.jar:na]
at com.deep.ai.yolo.YoloService.init(YoloService.java:71) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]