0

I've been working on a project for a while and determined that it would be made much faster with the use of nd4j. I have spent many hours trying to use this library, but I always find more dependencies and errors.

I started in Processing, but when I discovered that nd4j suggested the use of Maven, I switched to Eclipse. I'm not very familiar with Eclipse or Maven, so I'm sure there's some fairly easy way to get all of the dependencies for nd4j and I just haven't figured it out yet.

Does anyone know where can find all of the required jars for nd4j or how I can use it in Eclipse (or Processing)?

Again, I'm not familiar with Eclipse or Maven, so step by step instructions would be great.

Thanks so much!

If any further information would be useful, I would be happy to provide it.

  • Just add the `` of [ND4J Native](https://mvnrepository.com/artifact/org.nd4j/nd4j-native/1.0.0-M1.1) to the `` section of your `pom.xml`? – dan1st Feb 05 '22 at 23:45
  • @dan1st I have that dependency, but I don't have the `scope` as `test`. Might that be the issue? I also don't have the comment above it, but I assume that it doesn't do any thing as it is, well, a comment. – Rowan Ackerman Feb 05 '22 at 23:52
  • No, you shouldn't set the scope to test and you also don't need to include the comment. After you added this, right-click on your project and select `Maven`>`Update Project` so Eclipse keeps up. – dan1st Feb 05 '22 at 23:54
  • @dan1st Do I need to do anything else? I'm still getting errors and I don't think I have all of the dependencies. I don't think doing `Update Project` did anything. – Rowan Ackerman Feb 06 '22 at 15:48

1 Answers1

0

Nd4j itself is just a library. You don't really "install" it. What I'm about to say is also in our docs at https://deeplearning4j.konduit.ai. If you can't find something, I would appreciate feedback on the github repo: https://github.com/eclipse/deeplearning4j/issues

All you do is include which backend you want to use. A backend is a library which implements the nd4j interface and interfaces with a native backend which consists of a combination of a c++ library and blas/lapack bindings.

Of note here is usually when folks are new to the library they sometimes just don't know maven. If you are not familiar with maven/gradle I would recommend you get familiar with them. We don't support downloading 1 off jars and trying to mix/match them on your own in eclipse. This is due to all the combinations of dependencies you can use to make the library fit your use case. Of course this has its own trade offs.

Learning maven is a bit outside the scope of this post but I would recommend the maven quickstart or the guide for your IDE. Eclipse/Intellij have great maven integration and I would suggest you learn it. Most of the java ecosystem assumes that you know this for consuming their libraries.

If maven/gradle is well understood then you need to pick whether to use CPU or GPU. For simplicity, I assume you will want to use a cpu backend. In that case, once you have maven/gradle setup use the latest version found on maven central. In this case, you'll want the nd4j-native-platform artifact. This will allow you to declare 1 line in your pom.xml that will configure/download all the dependencies for you. That will usually look like:

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

I would look at maven central itself to see what the latest version will be at a given time though: https://search.maven.org/artifact/org.nd4j/nd4j-native-platform/1.0.0-M1.1/jar

Adam Gibson
  • 3,055
  • 1
  • 10
  • 12
  • I also added the dependency `nd4j-api` and this gibes the error `The POM for org.nd4j:nd4j-api:jar:1.0.0-M1.1 is invalid, transitive dependencies (if any) will not be available: 4 problems were encountered while building the effective model for org.nd4j:nd4j-api:1.0.0-M1.1` when I do a `maven build`. Am I doing something wrong? – Rowan Ackerman Feb 07 '22 at 23:47
  • Thanks for responding. nd4j-api should already be a transitive dependency. You can verify this with mvn dependency:tree. Running that in the directory will show all of the dependencies being pulled in by the project. Could you post the full stack trace as a gist? Either way for now, feel free to add nd4j-api as a dependency (just copy/paste the declaration above and change the name to nd4j-api) and add that to your dependencies section. – Adam Gibson Feb 08 '22 at 04:19
  • I have that added to my dependencies already. When I run that, it gives `+- junit:junit:jar:4.11:test \n | \- org.hamcrest:hamcrest-core:jar:1.3:test \n +- org.nd4j:nd4j-native-platform:jar:1.0.0-M1.1:compile \n \- org.nd4j:nd4j-api:jar:1.0.0-M1.1:compile`. It doesn't print out the `\n`s obviously; I just put those in because you can't do line breaks in comments. – Rowan Ackerman Feb 08 '22 at 14:31
  • It looks like it could be a corrupted download or something. Could you delete your ~/.m2 and try again? What you're seeing is not remotely normal and usually weird stuff like this happens because of a bad internet connection. You can also run mvn with package -U (note the -U) to force maven to update everything. If you'd like please migrate to the community forums here: https://community.konduit.ai/ that will allow discussions in an easier format. Then we can post back the answer here once it's resolved. – Adam Gibson Feb 09 '22 at 03:20
  • Thanks so much! This worked perfectly. It runs now! It's still complaining about something for slf4j, but it runs just fine other than that! – Rowan Ackerman Feb 09 '22 at 21:20
  • That's just a warning and is fairly normal. Just ignore that. If you need extended logging just add logback-classic to your classpath. – Adam Gibson Feb 10 '22 at 02:13