title: ND4J libraries fail to load on initialization: Unsatisfied Link Error
body: <p>I'm making a program with deep4j and I'm having libraries issues when I try to initialize the program. It is saying that I am not able to load the libraries besides the fact I seem to have set the library path manually in the Java code below.</p>
  
  <blockquote>
  <pre><code>Failed to load for libnd4jcpu: java.lang.UnsatisfiedLinkError: no libnd4jcpu in java.library.path
  </code></pre>
  </blockquote>
  
  <p>I've tried to manually set the library load path and it still doesn't work. </p>
  
  <pre><code>    String libPathProperty = System.getProperty("java.library.path");
      System.setProperty("java.library.path", libPathProperty + ":/users/&lt;user&gt;/.javacpp/cache");
      System.out.println(System.getProperty("java.library.path"));
      System.setProperty("org.bytedeco.javacpp.logger.debug","true");
  </code></pre>
  
  <p>My Pom I believe is following the steps from <a href="https://nd4j.org/getstarted" rel="nofollow noreferrer">https://nd4j.org/getstarted</a>. I'm posting it below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.example.com&lt;/groupId&gt;
  &lt;version&gt;0.1.0&lt;/version&gt;
  &lt;name&gt;Example&lt;/name&gt;
  &lt;url&gt;example.com&lt;/url&gt;
  &lt;description&gt;Example&lt;/description&gt;
  &lt;artifactId&gt;Examole&lt;/artifactId&gt;
  &lt;packaging&gt;jar&lt;/packaging&gt;
  
  &lt;organization&gt;
      &lt;name&gt;example.com&lt;/name&gt;
  &lt;/organization&gt;
  
  &lt;properties&gt;
  
      &lt;!-- protobuf paths --&gt;
      &lt;protobuf.input.directory&gt;${project.basedir}/src/main/java/com/proto&lt;/protobuf.input.directory&gt;
      &lt;protobuf.output.directory&gt;${project.basedir}/src/main/java&lt;/protobuf.output.directory&gt;
      &lt;project.build.dir&gt;${project.basedir}/build&lt;/project.build.dir&gt;
  
      &lt;!-- library versions --&gt;
      &lt;build-helper-maven-plugin.version&gt;1.9.1&lt;/build-helper-maven-plugin.version&gt;
      &lt;maven-antrun-plugin.version&gt;1.8&lt;/maven-antrun-plugin.version&gt;
      &lt;maven-dependency-plugin.version&gt;2.10&lt;/maven-dependency-plugin.version&gt;
      &lt;maven-shade-plugin.version&gt;2.4.2&lt;/maven-shade-plugin.version&gt;
      &lt;os-maven-plugin.version&gt;1.4.1.Final&lt;/os-maven-plugin.version&gt;
      &lt;protobuf.version&gt;3.0.0&lt;/protobuf.version&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;nd4j.version&gt;0.9.1&lt;/nd4j.version&gt;
      &lt;arbiter.version&gt;0.9.1&lt;/arbiter.version&gt;
      &lt;!-- nlp versions --&gt;
      &lt;stanfordnlp.version&gt;3.9.1&lt;/stanfordnlp.version&gt;
      &lt;outputDirectory&gt;/users/example/workspace/examplet/build/classes&lt;/outputDirectory&gt;
  &lt;/properties&gt;
  
  
  &lt;dependencies&gt;
  
  
      &lt;!--Standard Packages--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.protobuf&lt;/groupId&gt;
          &lt;artifactId&gt;protobuf-java&lt;/artifactId&gt;
          &lt;version&gt;${protobuf.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.googlecode.json-simple&lt;/groupId&gt;
          &lt;artifactId&gt;json-simple&lt;/artifactId&gt;
          &lt;version&gt;1.1.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;4.11&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
  
      &lt;!--NLP Packages--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
          &lt;artifactId&gt;stanford-corenlp&lt;/artifactId&gt;
          &lt;version&gt;${stanfordnlp.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;edu.stanford.nlp&lt;/groupId&gt;
          &lt;artifactId&gt;stanford-corenlp&lt;/artifactId&gt;
          &lt;version&gt;${stanfordnlp.version}&lt;/version&gt;
          &lt;classifier&gt;models&lt;/classifier&gt; &lt;!--  will get the dependent model jars --&gt;
      &lt;/dependency&gt;
  
  
      &lt;!--ML Packages--&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;nz.ac.waikato.cms.weka&lt;/groupId&gt;
          &lt;artifactId&gt;weka-stable&lt;/artifactId&gt;
          &lt;version&gt;3.8.0&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;nz.ac.waikato.cms.weka&lt;/groupId&gt;
          &lt;artifactId&gt;LibSVM&lt;/artifactId&gt;
          &lt;version&gt;1.0.10&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!--DL Packages--&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.deeplearning4j&lt;/groupId&gt;
          &lt;artifactId&gt;deeplearning4j-nlp&lt;/artifactId&gt;
          &lt;version&gt;0.9.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.nd4j&lt;/groupId&gt;
          &lt;artifactId&gt;nd4j-native-platform&lt;/artifactId&gt;
          &lt;version&gt;${nd4j.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.nd4j&lt;/groupId&gt;
          &lt;artifactId&gt;nd4j-native&lt;/artifactId&gt;
          &lt;version&gt;${nd4j.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.datavec&lt;/groupId&gt;
          &lt;artifactId&gt;datavec-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.0-alpha&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!--BLAS is used as a backend for libnd4j computations--&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.bytedeco.javacpp-presets&lt;/groupId&gt;
          &lt;artifactId&gt;openblas&lt;/artifactId&gt;
          &lt;version&gt;0.2.20-1.4.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.bytedeco&lt;/groupId&gt;
          &lt;artifactId&gt;javacpp&lt;/artifactId&gt;
          &lt;version&gt;1.4.1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!--Tuning Packages--&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.deeplearning4j&lt;/groupId&gt;
          &lt;artifactId&gt;arbiter-ui_2.11&lt;/artifactId&gt;
          &lt;version&gt;${arbiter.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.deeplearning4j&lt;/groupId&gt;
          &lt;artifactId&gt;arbiter-deeplearning4j&lt;/artifactId&gt;
          &lt;version&gt;${arbiter.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!--Logging Packages--&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-jdk14&lt;/artifactId&gt;
          &lt;version&gt;1.7.25&lt;/version&gt;
      &lt;/dependency&gt;
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;extensions&gt;
          &lt;!-- provides os.detected.classifier (i.e. linux-x86_64, osx-x86_64) property --&gt;
          &lt;extension&gt;
              &lt;groupId&gt;kr.motd.maven&lt;/groupId&gt;
              &lt;artifactId&gt;os-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;${os-maven-plugin.version}&lt;/version&gt;
          &lt;/extension&gt;
      &lt;/extensions&gt;
  
      &lt;directory&gt;${project.build.dir}/classes&lt;/directory&gt;
      &lt;outputDirectory&gt;${outputDirectory}&lt;/outputDirectory&gt;
  
      &lt;plugins&gt;
  
          &lt;!-- copy protoc binary into build directory --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven-dependency-plugin.version}&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-protoc&lt;/id&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;artifactItems&gt;
                              &lt;artifactItem&gt;
                                  &lt;groupId&gt;com.google.protobuf&lt;/groupId&gt;
                                  &lt;artifactId&gt;protoc&lt;/artifactId&gt;
                                  &lt;version&gt;${protobuf.version}&lt;/version&gt;
                                  &lt;classifier&gt;${os.detected.classifier}&lt;/classifier&gt;
                                  &lt;type&gt;exe&lt;/type&gt;
                                  &lt;overWrite&gt;true&lt;/overWrite&gt;
                                  &lt;outputDirectory&gt;${project.build.dir}&lt;/outputDirectory&gt;
                              &lt;/artifactItem&gt;
                          &lt;/artifactItems&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
          &lt;!-- compile proto file into java files. --&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;com.github.os72&lt;/groupId&gt;
              &lt;artifactId&gt;protoc-jar-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.5.1.1&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;!-- &lt;includeDirectories&gt; &lt;include&gt;src/main/protobuf&lt;/include&gt; &lt;/includeDirectories&gt; --&gt;
                          &lt;inputDirectories&gt;
                              &lt;include&gt;src/main/protobuf&lt;/include&gt;
                          &lt;/inputDirectories&gt;
                          &lt;!-- Create java files. And put them in the src/main/java directory. --&gt;
                          &lt;outputTargets&gt;
                              &lt;outputTarget&gt;
                                  &lt;type&gt;java&lt;/type&gt;
                                  &lt;outputDirectory&gt;src/main/java&lt;/outputDirectory&gt;
                              &lt;/outputTarget&gt;
                          &lt;/outputTargets&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
           &lt;!--compile proto buffer files using copied protoc binary--&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven-antrun-plugin.version}&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;exec-protoc&lt;/id&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;target&gt;
                              &lt;property name="protoc.filename" value="protoc-${protobuf.version}-${os.detected.classifier}.exe"/&gt;
                              &lt;property name="protoc.filepath" value="${project.build.dir}/${protoc.filename}"/&gt;
                              &lt;chmod file="${protoc.filepath}" perm="ugo+rx"/&gt;
                              &lt;mkdir dir="${protobuf.output.directory}" /&gt;
                              &lt;path id="protobuf.input.filepaths.path"&gt;
                                  &lt;fileset dir="${protobuf.input.directory}"&gt;
                                      &lt;include name="**/*.proto"/&gt;
                                  &lt;/fileset&gt;
                              &lt;/path&gt;
                              &lt;pathconvert pathsep=" " property="protobuf.input.filepaths" refid="protobuf.input.filepaths.path"/&gt;
                              &lt;exec executable="${protoc.filepath}" failonerror="true"&gt;
                                  &lt;arg value="-I"/&gt;
                                  &lt;arg value="${protobuf.input.directory}"/&gt;
                                  &lt;arg value="--java_out"/&gt;
                                  &lt;arg value="${protobuf.output.directory}"/&gt;
                                  &lt;arg line="${protobuf.input.filepaths}"/&gt;
                              &lt;/exec&gt;
                          &lt;/target&gt;
                      &lt;/configuration&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.xolstice.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;protobuf-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.5.0&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;protocExecutable&gt;/usr/local/bin/protoc&lt;/protocExecutable&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;test-compile&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
          &lt;!--&lt;plugin&gt;--&gt;
              &lt;!--&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;--&gt;
              &lt;!--&lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;--&gt;
              &lt;!--&lt;version&gt;2.1&lt;/version&gt;--&gt;
              &lt;!--&lt;executions&gt;--&gt;
                  &lt;!--&lt;execution&gt;--&gt;
                      &lt;!--&lt;phase&gt;package&lt;/phase&gt;--&gt;
                      &lt;!--&lt;goals&gt;--&gt;
                          &lt;!--&lt;goal&gt;shade&lt;/goal&gt;--&gt;
                      &lt;!--&lt;/goals&gt;--&gt;
                      &lt;!--&lt;configuration&gt;--&gt;
                          &lt;!--&lt;transformers&gt;--&gt;
                              &lt;!--&lt;transformer--&gt;
                                      &lt;!--implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;--&gt;
                                  &lt;!--&lt;mainClass&gt;main.java.com.chatbot.Main&lt;/mainClass&gt;--&gt;
                              &lt;!--&lt;/transformer&gt;--&gt;
                          &lt;!--&lt;/transformers&gt;--&gt;
                      &lt;!--&lt;/configuration&gt;--&gt;
                  &lt;!--&lt;/execution&gt;--&gt;
              &lt;!--&lt;/executions&gt;--&gt;
          &lt;!--&lt;/plugin&gt;--&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.2.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;mainClass&gt;com.chatbot.Main&lt;/mainClass&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
              &lt;version&gt;${maven-shade-plugin.version}&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;shadedArtifactAttached&gt;true&lt;/shadedArtifactAttached&gt;
                  &lt;shadedClassifierName&gt;${shadedClassifier}&lt;/shadedClassifierName&gt;
                  &lt;createDependencyReducedPom&gt;true&lt;/createDependencyReducedPom&gt;
                  &lt;filters&gt;
                      &lt;filter&gt;
                          &lt;artifact&gt;*:*&lt;/artifact&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;org/datanucleus/**&lt;/exclude&gt;
                              &lt;exclude&gt;META-INF/*.SF&lt;/exclude&gt;
                              &lt;exclude&gt;META-INF/*.DSA&lt;/exclude&gt;
                              &lt;exclude&gt;META-INF/*.RSA&lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/filter&gt;
                  &lt;/filters&gt;
  
              &lt;/configuration&gt;
  
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;phase&gt;package&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;shade&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;transformers&gt;
                              &lt;transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"&gt;
                                  &lt;resource&gt;reference.conf&lt;/resource&gt;
                              &lt;/transformer&gt;
                              &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/&gt;
                              &lt;transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                              &lt;/transformer&gt;
                          &lt;/transformers&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  
  
      &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>But I keep running into errors in that it won't load the libraries. Here's my output currently:</p>
  
  <pre><code>&gt; Loading class org.nd4j.nativeblas.Nd4jCpu
  &gt;     Loading class org.nd4j.nativeblas.Nd4jCpu
  &gt;     Loading library libnd4jcpu
  &gt;     Failed to load for libnd4jcpu: java.lang.UnsatisfiedLinkError: no libnd4jcpu in java.library.path
  &gt;     Loading /users/example/.javacpp/cache/nd4j-native-0.9.1-macosx-x86_64.jar/org/nd4j/nativeblas/macosx-x86_64/libnd4jcpu.dylib
  &gt;     Loading /users/example/.javacpp/cache/nd4j-native-0.9.1-macosx-x86_64.jar/org/nd4j/nativeblas/macosx-x86_64/libjnind4jcpu.dylib
  &gt;     Loading library libnd4jcpu
  &gt;     Failed to load for libnd4jcpu: java.lang.UnsatisfiedLinkError: no libnd4jcpu in java.library.path
  &gt;     Loading class org.bytedeco.javacpp.openblas
  &gt;     Loading class org.bytedeco.javacpp.openblas
  &gt;     Loading library iomp5
  &gt;     Failed to load for iomp5: java.lang.UnsatisfiedLinkError: no iomp5 in java.library.path
  &gt;     Loading library mkl_core
  &gt;     Failed to load for mkl_core: java.lang.UnsatisfiedLinkError: no mkl_core in java.library.path
  &gt;     Loading library mkl_avx
  &gt;     Failed to load for mkl_avx: java.lang.UnsatisfiedLinkError: no mkl_avx in java.library.path
  &gt;     Loading library mkl_avx2
  &gt;     Failed to load for mkl_avx2: java.lang.UnsatisfiedLinkError: no mkl_avx2 in java.library.path ....
  </code></pre>
  
  <p>I can see that libnd4jcpu does exist, so I'm not sure what's the issue. </p>
  
  <p>Computer: Macbook 2015 : No GPU</p>
  
  <p><strong>Update</strong> I ran the example MDPClassifer code from <a href="https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/feedforward/classification/MLPClassifierLinear.java" rel="nofollow noreferrer">https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/feedforward/classification/MLPClassifierLinear.java</a> and used the pom.xml file they had. I had the same problem</p>