当前位置: 首页 > 工具软件 > LibND4J > 使用案例 >

【Nd4j 运行异常解决方案】

滕祯
2023-12-01

Nd4j 运行异常解决方案

使用Nd4j版本

      <dependency>
          <groupId>org.nd4j</groupId>
          <artifactId>nd4j-native</artifactId>
          <version>1.0.0-M1.1</version>
      </dependency>

本地开发环境运行正常,但部署到服务器环境运行异常

java.lang.ExceptionInInitializerError
    at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init> (NativeOpExecutioner.java:78)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at java.lang.Class.newInstance (Class.java:442)
    at org.nd4j.linalg.factory.Nd4j.initWithBackend (Nd4j.java:5178)
    at org.nd4j.linalg.factory.Nd4j.initContext (Nd4j.java:5093)
    at org.nd4j.linalg.factory.Nd4j.<clinit> (Nd4j.java:270)
    at HelloNd4j.main (HelloNd4j.java:5)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.RuntimeException: ND4J is probably missing dependencies. For more information, please refer to: https://deeplearning4j.konduit.ai/nd4j/backend
    at org.nd4j.nativeblas.NativeOpsHolder.<init> (NativeOpsHolder.java:116)
    at org.nd4j.nativeblas.NativeOpsHolder.<clinit> (NativeOpsHolder.java:37)
    at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init> (NativeOpExecutioner.java:78)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at java.lang.Class.newInstance (Class.java:442)
    at org.nd4j.linalg.factory.Nd4j.initWithBackend (Nd4j.java:5178)
    at org.nd4j.linalg.factory.Nd4j.initContext (Nd4j.java:5093)
    at org.nd4j.linalg.factory.Nd4j.<clinit> (Nd4j.java:270)
    at HelloNd4j.main (HelloNd4j.java:5)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: no jnind4jcpu in java.library.path
    at java.lang.ClassLoader.loadLibrary (ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0 (Runtime.java:870)
    at java.lang.System.loadLibrary (System.java:1122)
    at org.bytedeco.javacpp.Loader.loadLibrary (Loader.java:1718)
    at org.bytedeco.javacpp.Loader.load (Loader.java:1328)
    at org.bytedeco.javacpp.Loader.load (Loader.java:1132)
    at org.nd4j.nativeblas.Nd4jCpu.<clinit> (Nd4jCpu.java:14)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:348)
    at org.nd4j.common.config.ND4JClassLoading.loadClassByName (ND4JClassLoading.java:62)
    at org.nd4j.common.config.ND4JClassLoading.loadClassByName (ND4JClassLoading.java:56)
    at org.nd4j.nativeblas.NativeOpsHolder.<init> (NativeOpsHolder.java:88)
    at org.nd4j.nativeblas.NativeOpsHolder.<clinit> (NativeOpsHolder.java:37)
    at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init> (NativeOpExecutioner.java:78)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at java.lang.Class.newInstance (Class.java:442)
    at org.nd4j.linalg.factory.Nd4j.initWithBackend (Nd4j.java:5178)
    at org.nd4j.linalg.factory.Nd4j.initContext (Nd4j.java:5093)
    at org.nd4j.linalg.factory.Nd4j.<clinit> (Nd4j.java:270)
    at HelloNd4j.main (HelloNd4j.java:5)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)
Caused by: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/nd4j-native-1.0.0-M1.1-linux-x86_64.jar/org/nd4j/nativeblas/linux-x86_64/libjnind4jcpu.so: /lib64/libm.so.6: version `GLIBC_2.23' not found (required by /root/.javacpp/cache/nd4j-native-1.0.0-M1.1-linux-x86_64.jar/org/nd4j/nativeblas/linux-x86_64/libnd4jcpu.so)
    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 org.bytedeco.javacpp.Loader.loadLibrary (Loader.java:1668)
    at org.bytedeco.javacpp.Loader.load (Loader.java:1328)
    at org.bytedeco.javacpp.Loader.load (Loader.java:1132)
    at org.nd4j.nativeblas.Nd4jCpu.<clinit> (Nd4jCpu.java:14)
    at java.lang.Class.forName0 (Native Method)
    at java.lang.Class.forName (Class.java:348)
    at org.nd4j.common.config.ND4JClassLoading.loadClassByName (ND4JClassLoading.java:62)
    at org.nd4j.common.config.ND4JClassLoading.loadClassByName (ND4JClassLoading.java:56)
    at org.nd4j.nativeblas.NativeOpsHolder.<init> (NativeOpsHolder.java:88)
    at org.nd4j.nativeblas.NativeOpsHolder.<clinit> (NativeOpsHolder.java:37)
    at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init> (NativeOpExecutioner.java:78)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance (Constructor.java:423)
    at java.lang.Class.newInstance (Class.java:442)
    at org.nd4j.linalg.factory.Nd4j.initWithBackend (Nd4j.java:5178)
    at org.nd4j.linalg.factory.Nd4j.initContext (Nd4j.java:5093)
    at org.nd4j.linalg.factory.Nd4j.<clinit> (Nd4j.java:270)
    at HelloNd4j.main (HelloNd4j.java:5)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:748)

解决方案:

提示:尝试降低版本

例如:

      <dependency>
          <groupId>org.nd4j</groupId>
          <artifactId>nd4j-native</artifactId>
          <version>1.0.0-beta7</version>
      </dependency>

直到运行成功,免去升级系统lib库的烦恼

 类似资料: