Run MXNet Scala Examples Using the IntelliJ IDE

This tutorial guides you through setting up a Scala project in the IntelliJ IDE and shows how to use an MXNet package from your application.

Prerequisites:

To use this tutorial, you need:

Set Up Your Project

  • Install the plugin for IntelliJ IDE by following these steps: On Menu, choose Preferences, choose Plugins, type Scala, and then choose Install.
  • Follow the instructions for Scala plugin setup for IDE.
  • When you build the MXNet package with Scala, a JAR file called mxnet-full_${scala.binary.version}-${platform} is generated in native/<your-architecture>/target directory. You need this file to create an example package that has a dependency on MXNet.
  • Specify project dependencies in pom.xml:
    <dependencies>
      <dependency>
        <groupId>ml.dmlc.mxnet</groupId>
        <artifactId>mxnet-full_${scala.binary.version}-${platform}</artifactId>
        <version>0.1.1</version>
        <scope>system</scope>
        <systemPath>`MXNet-Scala-jar-path`</systemPath>
      </dependency>
      <dependency>
        <groupId>args4j</groupId>
        <artifactId>args4j</artifactId>
        <version>2.0.29</version>
      </dependency>
    </dependencies>

Be sure to change the system path of MXNet-Scala-jar, which is in the native/<your-architecture>/target directory.

  • Choose the example project, choose Maven, and then reimport. These steps add all of the dependencies in pom.xml as external libraries in your project.
  • To build the project, choose Menu, choose Build, and then choose Rebuild Project. If errors are reported in the IDE, address them.
  • You can also compile the project by using the following command at the command line.
    cd mxnet-scala-example
    mvn clean package
  • This also generates a file called mxnet-scala-example-0.1-SNAPSHOT.jar for your application.

Next Steps

For more information about MXNet Scala resources, see the following: