The first step is to obtain the mxnet library. We recommend you build it from source. Also, you can download the library from
Refer to Build From Source
For MacOS users:
# Install OS X Developer Tools $ xcode-select --install # Install Homebrew $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" # Install dependencies $ brew install cmake ninja ccache opencv
# Clone 3rd dependency for mxnet. It's necessary $ git submodule update --init --recursive
# select and copy cmake configure files for macos $ cp config/darwin.cmake config.cmake # create build directory for prpject $ mkdir build; cd build # cmake $ cmake .. $ cmake --build .
Libraries will be generated under the directory build/.
For Linux users:
Docker might help you build libraries on different platforms. You can get help from README for CI.
For example, you can build mxnet on Ubuntu with by the following command.
$ python3 ci/build.py -p ubuntu_cpu
You can find the mxnet library from installed packages for mxnet, like python module. However, mxnet 2.0 is not released yet, that's why we recommend you build it from source.
# download python module for mxnet (have to mention that mxnet 2.0 hasn't been released by now) $ pip3 install mxnet==1.7.0.post2 # find the location of the installed module $ python Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46) >>> import mxnet >>> mxnet <module 'mxnet' from '/Users/xxx/anaconda3/lib/python3.6/site-packages/mxnet/__init__.py'> >>> quit() # you can locate the module under /Users/xxx/anaconda3/lib/python3.6/site-packages/mxnet/ $ ls /Users/xxx/anaconda3/lib/python3.6/site-packages/mxnet/ | grep libmxnet libmxnet.dylib
The compiled library is the file with the name of libmxnet.*. For MacOS, you will receive the file with suffix .dylib; For Linux, the lib file have the suffix “.so”; For Windows, the suffix is “.”
The project uses gradle to manage dependencies. You can build the project using gradle. We have to encapsulate the mxnet library into a jar file so that we can load it into JVM.
$ cd java-package # Build the project $ ./gradlew build # Create gradle tasks to package mxnet library into jar # The task name is in this form {$favor}-{$platform}Jar # MacOS -> mkl-osxJar # Linux -> mkl-linuxJar # Windows -> mkl-winJar $ ./gradlew :native:buildLocalLibraryJarDefault # Build native lib for macos $ ./gradlew mkl-osxJar # Check the lib for osx $ ls native/build/libs | grep osx native-2.0.0-SNAPSHOT-osx-x86_64.jar
The jar file native-2.0.0-SNAPSHOT-osx-x86_64.jar is the output lib file.
When we execute the task for integration test, the built mxnet native lib will be added into classpath automatically.
$ ./gradlew :integration:run