"no jnind4jcpu in java.library.path" when using Linux

I am attempting to build an uberjar of dl4j libraries for individual operating systems, using the following POM file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>joehot200</groupId>
    <artifactId>AntiAuraML-64</artifactId>
    <version>2.0</version>


    <properties>
        <dl4j.version>1.0.0-M2</dl4j.version>
        <fully.qualified.main.class>main.java.KillauraML</fully.qualified.main.class>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>

    </properties>

    <dependencies>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-nn</artifactId>
            <version>${dl4j.version}</version>
            <!--<exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>-->
        </dependency>
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-modelimport</artifactId>
            <version>${dl4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native</artifactId>
            <version>1.0.0-M2</version>
        </dependency>
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native-platform</artifactId>
            <version>1.0.0-M2</version>
            <!--   <classifier>windows-x86_64</classifier>-->
              <!-- <classifier>windows-x86_64</classifier> -->
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>classworlds:classworlds</exclude>
                                    <exclude>junit:junit</exclude>
                                    <exclude>jmock:*</exclude>
                                    <exclude>*:xml-apis</exclude>
                                    <exclude>org.apache.maven:lib:tests</exclude>
                                    <exclude>log4j:log4j:jar:</exclude>
                                </excludes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I then build with a run configuration in IntelliJ specifying the operating system. For example:

However, when building with linux (" -Djavacpp.platform=linux-x86_64 "), dl4j wont load.

java.lang.ExceptionInInitializerError: null
	at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.<init>(NativeOpExecutioner.java:79) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ~[?:?]
	at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350) ~[?:?]
	at java.lang.Class.newInstance(Class.java:642) ~[?:?]
	at org.nd4j.linalg.factory.Nd4j.initWithBackend(Nd4j.java:5129) ~[?:?]
	at org.nd4j.linalg.factory.Nd4j.initContext(Nd4j.java:5044) ~[?:?]
	at org.nd4j.linalg.factory.Nd4j.<clinit>(Nd4j.java:269) ~[?:?]
	at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetworkHelper(ModelSerializer.java:282) ~[?:?]
	at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:237) ~[?:?]
	at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:221) ~[?:?]
	at org.deeplearning4j.util.ModelSerializer.restoreMultiLayerNetwork(ModelSerializer.java:207) ~[?:?]
	at joehot200.checks.machinelearning.KillauraML.loadNetwork(KillauraML.java:141) ~[?:?]
	at joehot200.checktype.MachineLearningCheck.loadModel(MachineLearningCheck.java:172) ~[?:?]
	at joehot200.checktype.MachineLearningCheck$2.run(MachineLearningCheck.java:153) ~[?:?]
	at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Purpur-1171]
	at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.5.jar:git-Purpur-1171]
	at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1083) ~[patched_1.16.5.jar:git-Purpur-1171]
	at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:293) ~[patched_1.16.5.jar:git-Purpur-1171]
	at java.lang.Thread.run(Thread.java:831) [?:?]
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) ~[?:?]
	... 23 more
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) ~[?:?]
	... 23 more
Caused by: java.lang.UnsatisfiedLinkError: /root/.javacpp/cache/AntiAuraML-linux-64.jar/org/nd4j/linalg/cpu/nativecpu/bindings/linux-x86_64/libjnind4jcpu.so: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /root/.javacpp/cache/AntiAuraML-linux-64.jar/org/nd4j/linalg/cpu/nativecpu/bindings/linux-x86_64/libjnind4jcpu.so)
	at jdk.internal.loader.NativeLibraries.load(Native Method) ~[?:?]
	at jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383) ~[?:?]
	at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227) ~[?:?]
	at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169) ~[?:?]
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383) ~[?:?]
	at java.lang.Runtime.load0(Runtime.java:746) ~[?:?]
	at java.lang.System.load(System.java:1857) ~[?:?]
	at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1747) ~[?:?]
	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) ~[?:?]
	... 23 more

Here is my OS info:

root@endcraft:~# hostnamectl
   Static hostname: endcraft.net
         Icon name: computer-container
           Chassis: container
           Boot ID: b973ebd274654ad9bafd46ac3ae377f8
    Virtualization: openvz
  Operating System: Ubuntu 14.04.1 LTS
            Kernel: Linux 3.13.0-957.12.2.vz7.96.21
      Architecture: x86_64

I`m really lost on this (maybe if I was a better programmer I would understand the issue better…) so help would be appreciated. Thanks!

That is the core of the issue. It looks like you are trying to run it on a system with a rather old libstdc++. The CXXABI_1.3.8 symbol is from GCC 4.9, which was released in 2014.

My good sir, I`ll have you know my 2012 VPS prefers the term “wonderfully vintage”. :wink:

Is there a workaround for this issue, or will I simply have to inform customers that DL4J will not work on older software? A fair few of my customers are unfortunately living in the stone age, which is partly why I have a 2012 VPS in the first place.

Also, how “new” does the version need to be for dl4j to work?

Thanks.

As long as you don’t need GPU support, you can try using the linux-x86_64-compat platform. It will be slower, as it can’t make use of newer optimizations, but it should still work even on the ancient systems.

For the regular version, I think it should be Ubuntu 18.04 at least.

Also, Konduit offers commercial engagements for any special needs you might have.

1 Like