Scenario
Currently, MXNet were built along with different language bindings such as Scala. However, as a software design aspective, Python and Scala are cosumer of MXNet itself. Any language binding should build on top of its own distribution. In that case, it will be easier for user to switch between different mxnet versions and language binding versions. Considering the fact that MXNet are available for more platforms, we cannot create each of them a single Scala package.
Tensorflow currently publish their distribution jar with only so files in. It widely used for customers for Andriod, Arm and all different platforms.
Design
We are going to publish standalone maven packages for MXNet native library (libmxnet.so)
Packages to release
- All these native packages will be released under maven groupId: org.apache.mxnet
- Each cuda and mkl varieties will have their own artifact id
- Different operating system will share the same artifact id, with specific classifiers:
- linux-x86_64
- osx-x86_64
- win-x86_64
- linux-arm
artifactId | pip release name | Type | Linux | OSX | Windows | Android |
mxnet-native-cu101mkl | mxnet-cu101mkl | GPU | Y | N | Y | N |
mxnet-native-cu101 | mxnet-cu101 | GPU | Y | N | Y | N |
mxnet-native-cu92mkl | mxnet-cu92mkl | GPU | Y | N | Y | N |
mxnet-native-cu92 | mxnet-cu92 | GPU | Y | N | Y | N |
mxnet-native-cu90mkl | mxnet-cu90mkl | GPU | Y | N | Y | N |
mxnet-native-cu90 | mxnet-cu90 | GPU | Y | N | Y | N |
mxnet-native-mkl | mxnet-mkl | CPU | Y | Y | Y | N |
mxnet-native-min | mxnet | CPU | Y | Y | Y | ? |
Layout in release jar
Native shared libraries
- Each mxnet shared library should use platform specific file name extension.
- Besides libmxnet, other dependencies should also be packaged into .jar file
- cuda library will NOT be part of the jar.
Location in the jar
All shared libraries will be put under /native/lib folder.
Properties file
The shared libraries must be cached on disk first at java runtime. To improve native library loading performance and error case validation, we added a mxnet.properties file int /native/lib folder.
The properties file contains following information:
- version: the version with build number that can unique identify each mxnet native library build.
- libraries: a comma delimited list of all files need to be cached on disk.
Here list files for each jar
Linux | OSX | Windows | Android | |
-mkl | /native/lib/mxnet.properties /native/lib/libmxnet.so /native/lib/libgfortran.so.3 /native/lib/libquadmath.so.0 /native/lib/libiomp5.so /native/lib/libmklml_intel.so /native/lib/libmkldnn.so.0 | /native/lib/mxnet.properties /native/lib/libmxnet.dylib /native/lib/libiomp5.dylib /native/lib/libmklml.dylib /native/lib/libmkldnn.0.dylib | /native/lib/mxnet.properties /native/lib/libmxnet.dll | |
-min | /native/lib/mxnet.properties /native/lib/libmxnet.so /native/lib/libgfortran.so.3 /native/lib/libquadmath.so.0 | /native/lib/mxnet.properties /native/lib/libmxnet.dylib | /native/lib/mxnet.properties /native/lib/libmxnet.dll | /native/lib/mxnet.properties /native/lib/libmxnet.so |
Example:
Following is a sample pom.xml file for consuming mxnet native library
<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"> <modelVersion>4.0.0</modelVersion> <dependency> <groupId>org.apache.mxnet</groupId> <artifactId>mxnet-native-mkl</artifactId> <version>1.5.0-SNAPSHOT</version> <classifier>osx-x86_64</classifier> <scope>runtime</scope> </dependency> </dependencies> </project>