Setup the MXNet Package for Java

The following instructions are provided for macOS and Ubuntu. Windows is not yet available.

Note: If you use IntelliJ or a similar IDE, you may want to follow the MXNet-Java on IntelliJ tutorial instead of these instructions.


Maven

Setup Instructions

Step 1. Install dependencies:

macOS Steps

brew update
brew tap caskroom/versions
brew cask install java8
brew install opencv
brew install maven

Ubuntu Steps

These scripts will install Maven and its dependencies. You will be running the Scala scripts because the MXNet-Java project has a dependency on the MXNet-Scala project.

wget https://raw.githubusercontent.com/apache/incubator-mxnet/master/ci/docker/install/ubuntu_core.sh
wget https://raw.githubusercontent.com/apache/incubator-mxnet/master/ci/docker/install/ubuntu_scala.sh
chmod +x ubuntu_core.sh
chmod +x ubuntu_scala.sh
sudo ./ubuntu_core.sh
sudo ./ubuntu_scala.sh

Step 2. Run the demo MXNet-Java project.

Go to the MXNet-Java demo project’s README and follow the directions to test the MXNet-Java package installation.

Maven Repository

MXNet-Java can be easily included in your Maven managed project. The Java packages are currently available as nightly builds on Maven. Add the following Maven repository to your pom.xml to fetch the Java packages :

<repositories>
    <repository>
      <id>Apache Snapshot</id>
      <url>https://repository.apache.org/content/groups/snapshots</url>
    </repository>
</repositories>

Also, add the dependency which corresponds to your platform to the dependencies tag :

Linux CPU

<dependency>
  <groupId>org.apache.mxnet</groupId>
  <artifactId>mxnet-full_2.11-linux-x86_64-cpu</artifactId>
  <version>1.4.0-SNAPSHOT</version>
</dependency>

Linux GPU

<dependency>
  <groupId>org.apache.mxnet</groupId>
  <artifactId>mxnet-full_2.11-linux-x86_64-gpu</artifactId>
  <version>1.4.0-SNAPSHOT</version>
</dependency>

macOS CPU

<dependency>
  <groupId>org.apache.mxnet</groupId>
  <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
  <version>1.4.0-SNAPSHOT</version>
</dependency>

The official Java Packages will be released with the release of MXNet 1.4 and will be available on MXNet Maven package repository.


Source

The previously mentioned setup with Maven is recommended. Otherwise, the following instructions for macOS and Ubuntu are provided for reference only:

If you have already built mxnet from source using cmake, run make clean and then follow the appropriate guide below*

OS Step 1 Step 2
macOS Shared Library for macOS Scala Package for macOS
Ubuntu Shared Library for Ubuntu Scala Package for Ubuntu
Windows   Call for Contribution

Build Java from an Existing MXNet Installation

If you have already built MXNet from source and are looking to setup Java from that point, you may simply run the following from the MXNet source root:

make scalapkg
make scalainstall

This will install both the Java Inference API and the required MXNet-Scala package.


Documentation

Javadocs are generated as part of the docs build pipeline. You can find them published in the Java API section of the website or by going to the scaladocs output directly.

To build the docs yourself, follow the developer build docs instructions.