deepjavalibrary / djl

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

/libonnxruntime.so: libstdc++.so.6: cannot open shared object file: No such file or directory #2822

Closed hfwanggh closed 3 months ago

hfwanggh commented 12 months ago

When I run djl on CentOS7 I get an error: ‘’ java.lang.UnsatisfiedLinkError: /root/.djl.ai/paddle/2.3.2-cpu-linux-x86_64/libonnxruntime.so: libstdc++.so.6: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at ai.djl.paddlepaddle.jni.LibUtils.lambda$loadLinuxDependencies$0(LibUtils.java:109) at java.util.Arrays$ArrayList.forEach(Arrays.java:3880) at ai.djl.paddlepaddle.jni.LibUtils.loadLinuxDependencies(LibUtils.java:103) at ai.djl.paddlepaddle.jni.LibUtils.loadLibrary(LibUtils.java:70) ”

Before this, I have upgraded libstdc++.so.6.0.19 to 6.0.24, because 6.0.19 does not support CXXABI1.3.8, but after this error was solved, the above error occurred again, may I ask how to solve it?Thanks!

frankfliu commented 12 months ago

@hfwanggh Can you try to add libstdc++.so.6 to LD_LIBRARY_PATH?

hfwanggh commented 12 months ago

@hfwanggh Can you try to add libstdc++.so.6 to LD_LIBRARY_PATH? Thank you for answering that question. I tried it and it's still a problem, This time the mistake was : ''nested exception is java.lang.UnsatisfiedLinkError: /root/.djl.ai/paddle/2.2.2-20220429-cpu-linux-x86_64/libpaddle_inference.so: libiomp5.so: cannot open shared object file: No such file or directory] with root cause java.lang.UnsatisfiedLinkError: /root/.djl.ai/paddle/2.2.2-20220429-cpu-linux-x86_64/libpaddle_inference.so: libiomp5.so: cannot open shared object file: No such file or directory''

I'll describe the usage scenario in detail:

  1. I wanted to use paddleOCR, so I first tested it on windows following the example given by djl( http://docs.djl.ai/jupyter/paddlepaddle/paddle_ocr_java_zh.html ), and it worked fine with no problems. Here are the dependencies I used `

    ai.djl
        <artifactId>api</artifactId>
        <version>${djl.version}</version>
    </dependency>
    <dependency>
        <groupId>ai.djl.paddlepaddle</groupId>
        <artifactId>paddlepaddle-model-zoo</artifactId>
        <version>${djl.version}</version>
    </dependency>
    <dependency>
        <groupId>ai.djl.pytorch</groupId>
        <artifactId>pytorch-engine</artifactId>
        <version>${djl.version}</version>
    </dependency>`
  2. Then I want to port it to centos7 I wasn't sure if I should add the following dependency, but in fact I did `

    ai.djl.paddlepaddle
        <artifactId>paddlepaddle-native-cpu</artifactId>
        <classifier>linux-x86_64</classifier>
        <version>2.2.2</version>
        <scope>runtime</scope>
    </dependency>`

    Based on the above dependencies, I launched my application on centos, and when I tested it again, I experienced the current problem. I give the full error log here : " 2023-10-28 10:29:42.531 INFO 1939 --- [http-nio-8282-exec-1] ai.djl.util.Platform - Found matching platform from: jar:file:/home/otsapp/kefuWifi/test/message.jar!/BOOT-INF/lib/paddlepaddle-native-cpu-2.2.2-linux-x86_64.jar!/native/lib/paddlepaddle.properties 2023-10-28 10:29:42.533 INFO 1939 --- [http-nio-8282-exec-1] _ai.djl.paddlepaddle.jni.LibUtils -Paddle MKL/GPU requires user to set LD_LIBRARY_PATH=/root/.djl.ai/paddle/2.2.2-20220429-cpu-linux-x8664, the current one is set to: /usr/lib64 (libstdc++.so.6 is in this directory) 2023-10-28 10:29:42.896 ERROR 1939 --- [http-nio-8282-exec-1] o.a.c.c.C.[.[.[/message].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/message] threw exception [Handler dispatch failed; nested exception is java.lang.UnsatisfiedLinkError: /root/.djl.ai/paddle/2.2.2-20220429-cpu-linux-x86_64/libpaddle_inference.so: libiomp5.so: cannot open shared object file: No such file or directory] with root cause java.lang.UnsatisfiedLinkError: /root/.djl.ai/paddle/2.2.2-20220429-cpu-linux-x86_64/libpaddle_inference.so: libiomp5.so: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1086) at ai.djl.paddlepaddle.jni.LibUtils.loadLibrary(LibUtils.java:77) at ai.djl.paddlepaddle.engine.PpEngine.newInstance(PpEngine.java:43) at ai.djl.paddlepaddle.engine.PpEngineProvider.getEngine(PpEngineProvider.java:40) at ai.djl.engine.Engine.getEngine(Engine.java:190) at ai.djl.Model.newInstance(Model.java:99) at ai.djl.repository.zoo.BaseModelLoader.createModel(BaseModelLoader.java:191) at ai.djl.repository.zoo.BaseModelLoader.loadModel(BaseModelLoader.java:154) at ai.djl.repository.zoo.Criteria.loadModel(Criteria.java:172) at cn.stu.verifyboot.util.PaddleDemo.wordDetection(PaddleDemo.java:78) at cn.stu.verifyboot.controller.PaddleTest.paddleTest(PaddleTest.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1070) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) "

  3. According to the information I have consulted so far, I suspect that there is a problem with the previously upgraded libstdc++.so.6.0.24, which seems to be incompatible with my current centos. I am still verifying this problem.

    Finally, if you find any problems based on the information I have provided so far, please let me know. Thank you!

frankfliu commented 12 months ago

@hfwanggh Looks like you are using a fat jar. Can you run your spring boot project from source?

hfwanggh commented 12 months ago

@hfwanggh Looks like you are using a fat jar. Can you run your spring boot project from source?

"using a fat jar" What exactly does that mean?

My springboot project can start normally on IDEA without adding paddlepaddle-native cpu, and there is no problem in performing OCR recognition. However, errors will be reported when the project is packaged and executed on linux system.

frankfliu commented 12 months ago

@hfwanggh "fat jar" means you package the project into single ".jar" file. there are many restriction you using this approach. See this example: https://github.com/deepjavalibrary/djl-demo/tree/master/development/fatjar

hfwanggh commented 11 months ago

@hfwanggh "fat jar" means you package the project into single ".jar" file. there are many restriction you using this approach. See this example: https://github.com/deepjavalibrary/djl-demo/tree/master/development/fatjar

One more piece of information: just now I conducted a test in CentOS8 system, it ran successfully, it can work properly and return the result, still run as SpringBoot project jar package. As for CentOS7, it seems to be a bit troublesome, and I don't have a detailed and correct solution.