• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.mvn/wrapper/H04-Nov-2021-11567

assembly/H04-Nov-2021-272198

core/H04-Nov-2021-21,67212,993

deploy/H04-Nov-2021-125101

dev/H04-Nov-2021-257126

examples/H04-Nov-2021-11,7617,719

externalPom/H04-Nov-2021-223179

infer/H04-Nov-2021-2,6301,344

init/H04-Nov-2021-244121

init-native/H04-Nov-2021-357261

macros/H04-Nov-2021-1,560952

mxnet-demo/H04-Nov-2021-1,059680

native/H04-Nov-2021-4,0632,873

packageTest/H04-Nov-2021-620459

spark/H04-Nov-2021-2,0001,266

.gitignoreH A D04-Nov-2021559 1312

README.mdH A D04-Nov-202111.6 KiB251176

memory-management.mdH A D04-Nov-20218.5 KiB13698

mvnwH A D04-Nov-20218.9 KiB287194

mvnw.cmdH A D04-Nov-20215.8 KiB162129

pom.xmlH A D04-Nov-202115.1 KiB478442

scalastyle-config.xmlH A D04-Nov-20217.8 KiB171106

README.md

1<!--- Licensed to the Apache Software Foundation (ASF) under one -->
2<!--- or more contributor license agreements.  See the NOTICE file -->
3<!--- distributed with this work for additional information -->
4<!--- regarding copyright ownership.  The ASF licenses this file -->
5<!--- to you under the Apache License, Version 2.0 (the -->
6<!--- "License"); you may not use this file except in compliance -->
7<!--- with the License.  You may obtain a copy of the License at -->
8
9<!---   http://www.apache.org/licenses/LICENSE-2.0 -->
10
11<!--- Unless required by applicable law or agreed to in writing, -->
12<!--- software distributed under the License is distributed on an -->
13<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
14<!--- KIND, either express or implied.  See the License for the -->
15<!--- specific language governing permissions and limitations -->
16<!--- under the License. -->
17
18MXNet Package for Scala/Java
19=====
20
21The MXNet Scala/Java Package brings flexible and efficient GPU/CPU computing and state-of-art deep learning to the JVM.
22
23- It enables you to write seamless tensor/matrix computation with multiple GPUs
24  in Scala, Java and other JVM languages.
25- It also enables you to construct and customize the state-of-art deep learning models in JVM languages,
26  and apply them to tasks such as image classification and data science challenges.
27- The Scala/Java _Inference API_ provides an easy out of the box solution for performing inference tasks using pre-trained MXNet models.
28
29Pre-Built Maven Packages
30------------------------
31
32### Stable ###
33
34The MXNet Scala/Java packages can be easily included in your Maven managed project.
35The stable jar files for the packages are available on the [MXNet Maven Package Repository](https://search.maven.org/search?q=g:org.apache.mxnet).
36Currently we provide packages for Linux (Ubuntu 16.04) (CPU and GPU) and macOS (CPU only). Stable packages for Windows and CentOS will come soon. For now, if you have a CentOS machine, follow the ```Build From Source``` section below.
37
38To add the MXNet Scala/Java packages to your project, add the dependency as shown below corresponding to your platform, under the ```dependencies``` tag in your project's ```pom.xml``` :
39
40**Linux GPU**
41
42<a href="https://mvnrepository.com/artifact/org.apache.mxnet/mxnet-full_2.11-linux-x86_64-gpu"><img src="https://img.shields.io/badge/org.apache.mxnet-linux gpu-green.svg" alt="maven badge"/></a>
43
44```HTML
45<dependency>
46  <groupId>org.apache.mxnet</groupId>
47  <artifactId>mxnet-full_2.11-linux-x86_64-gpu</artifactId>
48  <version>[1.4.0,)</version>
49</dependency>
50```
51
52**Linux CPU**
53
54<a href="https://mvnrepository.com/artifact/org.apache.mxnet/mxnet-full_2.11-linux-x86_64-cpu"><img src="https://img.shields.io/badge/org.apache.mxnet-linux cpu-green.svg" alt="maven badge"/></a>
55
56```HTML
57<dependency>
58  <groupId>org.apache.mxnet</groupId>
59  <artifactId>mxnet-full_2.11-linux-x86_64-cpu</artifactId>
60  <version>[1.4.0,)</version>
61</dependency>
62```
63
64**macOS CPU**
65
66<a href="https://mvnrepository.com/artifact/org.apache.mxnet/mxnet-full_2.11-osx-x86_64-cpu"><img src="https://img.shields.io/badge/org.apache.mxnet-macOS cpu-green.svg" alt="maven badge"/></a>
67
68```HTML
69<dependency>
70  <groupId>org.apache.mxnet</groupId>
71  <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
72  <version>[1.4.0,)</version>
73</dependency>
74```
75
76**Note:** ```<version>[1.4.0,)<\version>``` indicates that we will fetch packages with version 1.4.0 or higher. This will always ensure that the pom.xml is able to fetch the latest and greatest jar files from Maven.
77
78### Nightly ###
79
80Apart from these, the nightly builds representing the bleeding edge development on Scala/Java packages are also available on the [MXNet Maven Nexus Package Repository](https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~~~~).
81Currently we provide nightly packages for Linux (CPU and GPU) and MacOS (CPU only). The Linux nightly jar files also work on CentOS. Nightly packages for Windows will come soon.
82
83Add the following ```repository``` to your project's ```pom.xml``` file :
84
85````html
86<repositories>
87    <repository>
88      <id>Apache Snapshot</id>
89      <url>https://repository.apache.org/content/groups/snapshots</url>
90    </repository>
91</repositories>
92````
93
94Also, add the dependency which corresponds to your platform to the ```dependencies``` tag :
95
96**Linux GPU**
97
98<a href="https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~mxnet-full_2.11-linux-x86_64-gpu~~~"><img src="https://img.shields.io/badge/org.apache.mxnet-linux gpu-green.svg" alt="maven badge"/></a>
99
100```HTML
101<dependency>
102  <groupId>org.apache.mxnet</groupId>
103  <artifactId>mxnet-full_2.11-linux-x86_64-gpu</artifactId>
104  <version>[1.9.0-SNAPSHOT,)</version>
105</dependency>
106```
107
108**Linux CPU**
109
110<a href="https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~mxnet-full_2.11-osx-x86_64-cpu~~~"><img src="https://img.shields.io/badge/org.apache.mxnet-linux cpu-green.svg" alt="maven badge"/></a>
111
112```HTML
113<dependency>
114  <groupId>org.apache.mxnet</groupId>
115  <artifactId>mxnet-full_2.11-linux-x86_64-cpu</artifactId>
116  <version>[1.9.0-SNAPSHOT,)</version>
117</dependency>
118```
119
120**macOS CPU**
121
122<a href="https://mvnrepository.com/artifact/org.apache.mxnet/mxnet-full_2.11-osx-x86_64-cpu"><img src="https://img.shields.io/badge/org.apache.mxnet-macOS cpu-green.svg" alt="maven badge"/></a>
123```HTML
124<dependency>
125  <groupId>org.apache.mxnet</groupId>
126  <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
127  <version>[1.9.0-SNAPSHOT,)</version>
128</dependency>
129```
130
131**Note:** ```<version>[1.9.0-SNAPSHOT,)</version>``` indicates that we will fetch packages with version 1.9.0 or higher. This will always ensure that the pom.xml is able to fetch the latest and greatest jar files from Maven Snapshot repository.
132
133Build From Source
134-----------------
135
136The [Installation Guide](https://mxnet.apache.org/get_started) contains instructions to install mxnet or build it from source. The Scala/Java package is built from source using Maven. The maven build assumes you already have a ``lib/libmxnet.so`` file.
137If you have built MXNet from source and are looking to set up Scala\Java from that point, you may simply run the following from the MXNet source root, the build will detect your platform (OSX/Linux) and libmxnet.so flavor (CPU/GPU):
138
139```bash
140cd scala-package
141mvn install
142```
143
144You can also run the unit tests and integration tests on the Scala Package by :
145
146```bash
147cd scala-package
148mvn integration-test -DskipTests=false
149```
150
151Or run a subset of unit tests, for e.g.,
152
153```bash
154cd scala-package
155mvn -Dsuites=org.apache.mxnet.NDArraySuite integration-test
156```
157
158If everything goes well, you will find jars for `assembly`, `core` and `example` modules.
159Also it produces the native library in `native/target`, which you can use in conjunction with the `core` module.
160
161Deploy to repository
162--------------------
163
164By default, `maven deploy` will deploy artifacts to local file system, you can find them in the ``scala-package/deploy/target/repo`` folder.
165
166For nightly builds (typically done by CI), a snapshot build will be uploaded to an apache snapshot repository with the following command:
167
168```bash
169cd scala-package
170mvn deploy -Pnightly
171```
172
173Use the following command when performing a release (pushes artifacts to an apache staging repository):
174
175```bash
176cd scala-package
177mvn deploy -Pstaging
178```
179
180Examples & Usage
181-------
182Assuming you use `mvn install`, you can find the `mxnet-full_scala_version-INTERNAL.jar` e.g. `mxnet-full_2.11-INTERNAL.jar` under the path `incubator-mxnet/scala-package/assembly/target`.
183
184Adding the following configuration in `pom.xml`
185```HTML
186<dependency>
187  <groupId>org.apache.mxnet</groupId>
188  <artifactId>mxnet-full_2.11-INTERNAL</artifactId>
189  <version>1.9.0</version>
190  <scope>system</scope>
191  <systemPath>path_to_jar/mxnet-full_2.11-INTERNAL.jar</systemPath>
192</dependency>
193```
194If you have following error message
195```
196Error: A JNI error has occurred, please check your installation and try again
197Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mxnet/NDArray
198        at java.lang.Class.getDeclaredMethods0(Native Method)
199        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
200        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
201        at java.lang.Class.getMethod0(Class.java:3018)
202        at java.lang.Class.getMethod(Class.java:1784)
203        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
204        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
205Caused by: java.lang.ClassNotFoundException: org.apache.mxnet.NDArray
206        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
207        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
208        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
209        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
210```
211Please make sure your $CLASSPATH contains `mxnet-full_scala_version-INTERNAL.jar`.
212
213- To set up the Scala Project using IntelliJ IDE on macOS follow the instructions [here](https://mxnet.apache.org/tutorials/scala/mxnet_scala_on_intellij.html).
214- Several examples on using the Scala APIs are provided in the [Scala Examples Folder](https://github.com/apache/incubator-mxnet/tree/master/scala-package/examples/)
215
216Scala Training APIs
217-------
218- Module API :
219[The Module API](https://mxnet.apache.org/api/scala/module.html) provides an intermediate and high-level interface for performing computation with neural networks in MXNet. Modules provide high-level APIs for training, predicting, and evaluating.
220
221- KVStore API :
222To run training over multiple GPUs and multiple hosts, one can use the [KVStore API](https://mxnet.apache.org/api/scala/kvstore.html).
223
224- IO/Data Loading :
225MXNet Scala provides APIs for preparing data to feed as an input to models. Check out [Data Loading API](https://mxnet.apache.org/api/scala/io.html) for more info.
226
227Other available Scala APIs for training can be found [here](https://mxnet.apache.org/api/scala/index.html).
228
229
230Scala Inference APIs
231-------
232The [Scala Inference APIs](https://mxnet.apache.org/api/scala/infer.html) provide an easy, out of the box solution to load a pre-trained MXNet model and run inference on it. The Inference APIs are present in the [Infer Package](https://github.com/apache/incubator-mxnet/tree/master/scala-package/infer) under the MXNet Scala Package repository, while the documentation for the Infer API is available [here](https://mxnet.apache.org/api/scala/docs/index.html#org.apache.mxnet.infer.package).
233
234Java Inference APIs
235-------
236The [Java Inference APIs](https://mxnet.apache.org/api/java/index.html) also provide an easy, out of the box solution to load a pre-trained MXNet model and run inference on it. The Inference APIs are present in the [Infer Package](https://github.com/apache/incubator-mxnet/tree/master/scala-package/infer/src/main/scala/org/apache/mxnet/infer/javaapi) under the MXNet Scala Package repository, while the documentation for the Infer API is available [here](https://mxnet.apache.org/api/java/docs/index.html#org.apache.mxnet.infer.package).
237More APIs will be added to the Java Inference APIs soon.
238
239JVM Memory Management
240-------
241The Scala/Java APIs also provide an automated resource management system, thus making it easy to manage the native memory footprint without any degradation in performance.
242More details about JVM Memory Management are available [here](https://github.com/apache/incubator-mxnet/blob/master/scala-package/memory-management.md).
243
244License
245-------
246MXNet Scala Package is licensed under [Apache-2](https://github.com/apache/incubator-mxnet/blob/master/scala-package/LICENSE) license.
247
248MXNet uses some 3rd party softwares. Following 3rd party license files are bundled inside Scala jar file:
249* cub/LICENSE.TXT
250* mkldnn/external/mklml_mac_2019.0.1.20180928/license.txt
251