Caused by: java.lang.UnsatisfiedLinkError: Could not find jnind4jcpu

I am getting this error on Linux operating systems. Windows works without any problems.

Caused by: java.lang.UnsatisfiedLinkError: no jnind4jcpu in java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2423) ~[?:?]
        at java.lang.Runtime.loadLibrary0(Runtime.java:808) ~[?:?]
        at java.lang.System.loadLibrary(System.java:1893) ~[?:?]
        at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1800) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1402) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1214) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1190) ~[?:?]
        at org.nd4j.linalg.cpu.nativecpu.bindings.Nd4jCpu.<clinit>(Nd4jCpu.java:14) ~[?:?]
        at java.lang.Class.forName0(Native Method) ~[?:?]
        at java.lang.Class.forName(Class.java:466) ~[?:?]
        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) ~[?:?]
        ... 39 more
Caused by: java.lang.UnsatisfiedLinkError: Could not find jnind4jcpu in class, module, and library paths.
        at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1767) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1402) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1214) ~[?:?]
        at org.bytedeco.javacpp.Loader.load(Loader.java:1190) ~[?:?]
        at org.nd4j.linalg.cpu.nativecpu.bindings.Nd4jCpu.<clinit>(Nd4jCpu.java:14) ~[?:?]
        at java.lang.Class.forName0(Native Method) ~[?:?]
        at java.lang.Class.forName(Class.java:466) ~[?:?]
        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) ~[?:?]
        ... 39 more

I really don`t understand how to solve it. I have currently tried importing EVERYTHING, I quite literally have a 1.7GB jar file at this point with these dependencies:

<properties>
        <dl4j-master.version>1.0.0-M2</dl4j-master.version>
        <!-- Change the nd4j.backend property to nd4j-cuda-X-platform to use CUDA GPUs -->
        <!-- <nd4j.backend>nd4j-cuda-10.2-platform</nd4j.backend> -->
        <nd4j.backend>nd4j-native-platform</nd4j.backend>
        <java.version>1.8</java.version>
        <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
        <maven.minimum.version>3.3.1</maven.minimum.version>
        <exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
        <maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
        <jcommon.version>1.0.23</jcommon.version>
        <jfreechart.version>1.0.13</jfreechart.version>
        <logback.version>1.1.7</logback.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.8.0-M1</junit.version>
        <javacv.version>1.5.5</javacv.version>

    </properties>

<dependencies>
		<dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>${nd4j.backend}</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>


        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-api</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-data-image</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-local</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-datasets</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-core</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>resources</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-ui</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-zoo</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>
        <!-- ParallelWrapper & ParallelInference live here -->
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-parallel-wrapper</artifactId>
            <version>${dl4j-master.version}</version>
        </dependency>

        <dependency>
            <groupId>org.bytedeco</groupId>
            <artifactId>javacv-platform</artifactId>
            <version>${javacv.version}</version>
        </dependency>

	</dependencies>

What is going on here and why is this going wrong?

@Joehot200 you’re missing the actual root cause. This always usually comes down to running on an older OS.

To verify the problem though, please set the system property:
org.bytedeco.javacpp.logger.debug to true.

You can do this by running on the command line with -Dorg.bytedeco.logger.debug=true
or in java with:

System.setProperty("org.bytedeco.javacpp.logger.debug","true");

What you’ll probably find running that is your OS being old. If that’s the case (you’re probably running on an old centos or something) then use the compat classifier.

<dependency>
  <groupId>org.nd4j</groupId>
  <artifactId>nd4j-native</artifactId>
  <version>1.0.0-M2</version>
</dependency>
<dependency>
  <groupId>org.nd4j</groupId>
  <artifactId>nd4j-native</artifactId>
  <version>1.0.0-M2</version>
 <classifier>linux-x86_64-compat</classifier>
</dependency>

You may also need the relevant openblas dependencies if you are not using nd4j-native-platform (we usually do this for you)
In that case add:

<dependency>
  <groupId>org.bytedeco</groupId>
  <artifactId>openblas</artifactId>
  <version>0.3.19-1.5.7</version>
</dependency>
<dependency>
  <groupId>org.bytedeco</groupId>
  <artifactId>openblas</artifactId>
  <version>0.3.19-1.5.7</version>
<classifier>linux-x86_64</classifier>
</dependency>

Note this is a common problem for any library not just ours. Any library that fails to load (especially with javacpp) usually has linker issues related to glibc. Libraries built with newer glibcs will always
error out like that on newer systems.

We build our libraries on reasonably old (ubuntu 18) OSes but for people who need older systems than that we provide a compat classifier. This allows the users to make the trade off of compatibility vs newer features and more performance.

Hi All,

I am also facing the same issue, even though I have added the nd4j classifier for linux.

11:32:13.030 [main] WARN org.deeplearning4j.nn.conf.inputs.InputType - Assigning a size of zero. This is normally only valid in model import cases with unknown dimensions.
11:32:13.200 [main] INFO org.nd4j.linalg.factory.Nd4jBackend - Loaded [CpuBacken d] backend
11:32:13.202 [main] ERROR org.nd4j.common.config.ND4JClassLoading - Cannot find class [org.nd4j.linalg.jblas.JblasBackend] of provided class-loader.
11:32:13.203 [main] ERROR org.nd4j.common.config.ND4JClassLoading - Cannot find class [org.canova.api.io.data.DoubleWritable] of provided class-loader.
11:32:13.204 [main] ERROR org.nd4j.common.config.ND4JClassLoading - Cannot find class [org.nd4j.linalg.jblas.JblasBackend] of provided class-loader.
11:32:13.205 [main] ERROR org.nd4j.common.config.ND4JClassLoading - Cannot find class [org.canova.api.io.data.DoubleWritable] of provided class-loader.
Exception in thread “main” java.lang.ExceptionInInitializerError
at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.(NativeOp Executioner.java:78)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java: 490)
at java.base/java.lang.Class.newInstance(Class.java:584)
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.(Nd4j.java:270)
at org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(Hdf5A rchive.java:295)
at org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(Hdf5A rchive.java:109)
at org.deeplearning4j.nn.modelimport.keras.utils.KerasModelUtils.importW eights(KerasModelUtils.java:284)
at org.deeplearning4j.nn.modelimport.keras.KerasSequentialModel.(K erasSequentialModel.java:151)
at org.deeplearning4j.nn.modelimport.keras.KerasSequentialModel.(K erasSequentialModel.java:57)
at org.deeplearning4j.nn.modelimport.keras.utils.KerasModelBuilder.build Sequential(KerasModelBuilder.java:326)
at org.deeplearning4j.nn.modelimport.keras.KerasModelImport.importKerasS equentialModelAndWeights(KerasModelImport.java:218)
at DlModel.sample.App.main(App.java:16)
Caused by: java.lang.RuntimeException: ND4J is probably missing dependencies. Fo r more information, please refer to: https://deeplearning4j.konduit.ai/nd4j/back end
at org.nd4j.nativeblas.NativeOpsHolder.(NativeOpsHolder.java:116)
at org.nd4j.nativeblas.NativeOpsHolder.(NativeOpsHolder.java:37)
… 17 more
Caused by: java.lang.UnsatisfiedLinkError: no jnind4jcpu in java.library.path: [ /usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2660)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:829)
at java.base/java.lang.System.loadLibrary(System.java:1867)
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.(Nd4jCpu.java:14)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at org.nd4j.common.config.ND4JClassLoading.loadClassByName(ND4JClassLoad ing.java:62)
at org.nd4j.common.config.ND4JClassLoading.loadClassByName(ND4JClassLoad ing.java:56)
at org.nd4j.nativeblas.NativeOpsHolder.(NativeOpsHolder.java:88)
… 18 more
Caused by: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/sample-0.0.1-SNAPSHOT-jar-with-dependencies.jar/org/nd4j/nativeblas/linux-x86_64/libjnind4jcpu.s o: /lib64/libstdc++.so.6: version `CXXABI_1.3.8’ not found (required by /root/.j avacpp/cache/sample-0.0.1-SNAPSHOT-jar-with-dependencies.jar/org/nd4j/nativeblas /linux-x86_64/libjnind4jcpu.so)
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2 430)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader .java:2487)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617)
at java.base/java.lang.Runtime.load0(Runtime.java:767)
at java.base/java.lang.System.load(System.java:1831)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1668)
… 26 more

It tells you right here what the problem is. You are most likely on a too old system install.