deepjavalibrary / djl

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

Ubuntu18.04 dynamic linked library error #1303

Closed ouyangshixiong closed 3 years ago

ouyangshixiong commented 3 years ago

Description

Can not load AI Model on ubuntu

Expected Behavior

can load AI model

Error Message

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Mnist': Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.6.jar:5.3.6] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782) [spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774) [spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439) [spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) [spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) [spring-boot-2.4.5.jar:2.4.5] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) [spring-boot-2.4.5.jar:2.4.5] at com.example.ai.ArknightAiOneApplication.main(ArknightAiOneApplication.java:14) [classes/:na] Caused by: java.lang.ExceptionInInitializerError: null at ai.djl.paddlepaddle.engine.PpEngine.newBaseManager(PpEngine.java:110) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpEngine.newModel(PpEngine.java:92) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.Model.newInstance(Model.java:98) ~[api-0.13.0.jar:na] at ai.djl.repository.zoo.BaseModelLoader.createModel(BaseModelLoader.java:187) ~[api-0.13.0.jar:na] at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:149) ~[api-0.13.0.jar:na] at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:166) ~[api-0.13.0.jar:na] at ai.djl.repository.zoo.ModelZoo.loadModel(ModelZoo.java:123) ~[api-0.13.0.jar:na] at com.example.ai.service.BaseServiceImpl.loadModel(BaseServiceImpl.java:90) ~[classes/:na] at com.example.ai.service.MnistServiceImpl.init(MnistServiceImpl.java:31) ~[classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_292] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_292] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_292] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_292] at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.6.jar:5.3.6] at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.6.jar:5.3.6] ... 19 common frames omitted Caused by: ai.djl.engine.EngineException: Failed to load PyTorch native library at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:77) ~[pytorch-engine-0.13.0.jar:na] at ai.djl.pytorch.engine.PtEngineProvider.getEngine(PtEngineProvider.java:40) ~[pytorch-engine-0.13.0.jar:na] at ai.djl.engine.Engine.getEngine(Engine.java:168) ~[api-0.13.0.jar:na] at ai.djl.engine.Engine.getInstance(Engine.java:133) ~[api-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpEngine.getAlternativeEngine(PpEngine.java:54) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.ndarray.BaseNDManager.getAlternativeManager(BaseNDManager.java:372) ~[api-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpNDManager.(PpNDManager.java:36) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpNDManager.(PpNDManager.java:28) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpNDManager$SystemManager.(PpNDManager.java:118) ~[paddlepaddle-engine-0.13.0.jar:na] at ai.djl.paddlepaddle.engine.PpNDManager.(PpNDManager.java:30) ~[paddlepaddle-engine-0.13.0.jar:na] ... 35 common frames omitted Caused by: java.lang.UnsatisfiedLinkError: /home/ouyang/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64/0.13.0-cpu-libdjl_torch.so: /home/ouyang/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64/0.13.0-cpu-libdjl_torch.so: undefined symbol: _ZN2at6detail10noopDeleteEPv at java.lang.ClassLoader$NativeLibrary.load(Native Method) ~[na:1.8.0_292] at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934) ~[na:1.8.0_292] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817) ~[na:1.8.0_292] at java.lang.Runtime.load0(Runtime.java:810) ~[na:1.8.0_292] at java.lang.System.load(System.java:1088) ~[na:1.8.0_292] at ai.djl.pytorch.jni.LibUtils.loadNativeLibrary(LibUtils.java:351) ~[pytorch-engine-0.13.0.jar:na] at ai.djl.pytorch.jni.LibUtils.loadLibrary(LibUtils.java:77) ~[pytorch-engine-0.13.0.jar:na] at ai.djl.pytorch.engine.PtEngine.newInstance(PtEngine.java:50) ~[pytorch-engine-0.13.0.jar:na] ... 44 common frames omitted

Process finished with exit code 1

Other information

ouyang@ouyang-ubuntu:~/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64$ ldd 0.13.0-cpu-libdjl_torch.so linux-vdso.so.1 (0x00007fff579ce000) libtorch.so => /home/ouyang/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64/./libtorch.so (0x00007ffb21d89000) libc10.so => /home/ouyang/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64/./libc10.so (0x00007ffb21afd000) libtorch_cpu.so => /home/ouyang/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64/./libtorch_cpu.so (0x00007ffb10005000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ffb0fc7c000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ffb0f8de000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ffb0f6c6000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffb0f2d5000) /lib64/ld-linux-x86-64.so.2 (0x00007ffb2231c000) libgomp-75eea7e8.so.1 (0x00007ffb0f0b0000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ffb0ee91000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ffb0ec89000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffb0ea85000) ouyang@ouyang-ubuntu:~/.djl.ai/pytorch/1.8.1-20210417-cpu-linux-x86_64$ uname -a Linux ouyang-ubuntu 5.4.0-87-generic #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

How to Reproduce?

Steps to reproduce

What have you tried to solve it?

  1. using Paddle to run my simple local AI Modle Mnist predictor
  2. original running successfully on my mac and on my CentOS8 Server using version 0.11.0
  3. failed to run on my local Ubuntu18.04 LTS desktop versoin, report null pointer exception
  4. upgrade to 0.13.0 versoin
  5. still failed to run, report error as show above

Environment Info

Please run the command ./gradlew debugEnv from the root directory of DJL (if necessary, clone DJL first). It will output information about your system, environment, and installation that can help us debug your issue. Paste the output of the command below:

PASTE OUTPUT HERE
frankfliu commented 3 years ago

@ouyangshixiong You should use pytorch 1.9.0, see: https://github.com/deepjavalibrary/djl/blob/master/engines/pytorch/pytorch-engine/README.md#installation

ouyangshixiong commented 2 years ago

Thank you!