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


artifactIdpip release nameTypeLinuxOSXWindowsAndroid
mxnet-native-cu101mklmxnet-cu101mklGPUYNYN
mxnet-native-cu101mxnet-cu101GPUYNYN
mxnet-native-cu92mklmxnet-cu92mklGPUYNYN
mxnet-native-cu92mxnet-cu92GPUYNYN
mxnet-native-cu90mklmxnet-cu90mklGPUYNYN
mxnet-native-cu90mxnet-cu90GPUYNYN
mxnet-native-mklmxnet-mklCPUYYYN
mxnet-native-minmxnetCPUYYY?







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:

  1. version: the version with build number that can unique identify each mxnet native library build.
  2. libraries: a comma delimited list of all files need to be cached on disk.


Here list files for each jar


LinuxOSXWindowsAndroid
-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

pom.xml
<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>




  • No labels