deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.13k stars 656 forks source link

Failed to load PyTorch native library #2117

Closed Songbo729066989 closed 2 years ago

Songbo729066989 commented 2 years ago

ai.djl.engine.EngineException: Failed to load PyTorch native library at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:82) at ai.djl.pytorch.engine.PtEngineProvider.getEngine(PtEngineProvider.java:40) at ai.djl.engine.Engine.getEngine(Engine.java:181) at ai.djl.Model.newInstance(Model.java:99) at ai.djl.repository.zoo.BaseModelLoader.createModel(BaseModelLoader.java:189) at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:152) at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:168)

Caused by: java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;)Lcom/sun/jna/Library; at ai.djl.util.cuda.CudaUtils.loadLibrary(CudaUtils.java:185) at ai.djl.util.cuda.CudaUtils.(CudaUtils.java:33) at ai.djl.util.Platform.fromSystem(Platform.java:188) at ai.djl.util.Platform.fromSystem(Platform.java:148) at ai.djl.util.Platform.detectPlatform(Platform.java:68) at ai.djl.pytorch.jni.LibUtils.findNativeLibrary(LibUtils.java:270) at ai.djl.pytorch.jni.LibUtils.getLibTorch(LibUtils.java:87) at ai.djl.pytorch.jni.LibUtils.loadLibrary(LibUtils.java:75) at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:53) ... 45 more

Songbo729066989 commented 2 years ago

version 0.16.0

frankfliu commented 2 years ago

Can you share you build.gradle or pom.xml file?

Looks like you have a conflict version JNA in your classpath

Songbo729066989 commented 2 years ago

Thanks for your timely reply, it was caused by jna version conflict. I fixed it by force a jna version.