Skip to content

Commit

Permalink
[MXNET-1232] fix demo and add Eclipse support (apache#13979)
Browse files Browse the repository at this point in the history
* fix demo and add Eclipse support

* fix on docs

* fix typo

* Update docs/install/java_setup.md

Co-Authored-By: lanking520 <lanking520@live.com>

* add fixes in docs
  • Loading branch information
lanking520 authored and stephenrawls committed Feb 16, 2019
1 parent b87f3ec commit c5c1dc7
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 141 deletions.
4 changes: 2 additions & 2 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1241,15 +1241,15 @@ nightly_tutorial_test_ubuntu_python2_gpu() {
nightly_java_demo_test_cpu() {
set -ex
cd /work/mxnet/scala-package/mxnet-demo/java-demo
make java_ci_demo
mvn -Pci-nightly install
bash bin/java_sample.sh
bash bin/run_od.sh
}

nightly_scala_demo_test_cpu() {
set -ex
cd /work/mxnet/scala-package/mxnet-demo/scala-demo
make scala_ci_demo
mvn -Pci-nightly install
bash bin/demo.sh
bash bin/run_im.sh
}
Expand Down
13 changes: 10 additions & 3 deletions docs/install/java_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ Also, add the dependency which corresponds to your platform to the `dependencies
The official Java Packages will be released with the release of MXNet 1.4 and will be available on [MXNet Maven package repository](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.mxnet%22).
<hr>

### Eclipse IDE Support
You can convert your existing Maven project to a project that can run in Eclipse by:
```
mvn eclipse:eclipse
```
This can be done once you have your maven project properly configured.

## Source

The previously mentioned setup with Maven is recommended. Otherwise, the following instructions for macOS and Ubuntu are provided for reference only:
Expand All @@ -99,11 +106,11 @@ The previously mentioned setup with Maven is recommended. Otherwise, the followi


#### Build Java from an Existing MXNet Installation
If you have already built MXNet **from source** and are looking to setup Java from that point, you may simply run the following from the MXNet source root:
If you have already built MXNet **from source** and are looking to setup Java from that point, you may simply run the following from the MXNet `scala-package` folder:

```
make scalapkg
make scalainstall
mvn package
mvn install
```
This will install both the Java Inference API and the required MXNet-Scala package.
<hr>
Expand Down
52 changes: 0 additions & 52 deletions scala-package/mxnet-demo/java-demo/Makefile

This file was deleted.

30 changes: 19 additions & 11 deletions scala-package/mxnet-demo/java-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# MXNet Java Sample Project
This is an project created to use Maven-published Scala/Java package with two Java examples.
## Setup
You can use the `Makefile` to make the Java package. Simply do the following:
```Bash
make javademo
You are required to use Maven to build the package with the following commands:
```
mvn package
```
This will load the default parameter for all the environment variable.
If you want to run with GPU on Linux, just simply add `USE_CUDA=1` when you run the make file

This command will pick the default values specified in the [pom](https://github.com/apache/incubator-mxnet/blob/master/scala-package/mxnet-demo/java-demo/pom.xml) file.

Note: If you are planning to use GPU, please add `-Dmxnet.profile=linux-x86_64-gpu`

### Use customized version set
You can use the following instruction as an alternative to achieve the same result:
User are required to use `mvn package` to build the package,
which are shown below:
You may use `mvn package` to build the package,
using the following commands:
```Bash
export SCALA_VERSION_PROFILE=2.11
export SCALA_PKG_PROFILE=
Expand Down Expand Up @@ -71,9 +73,15 @@ If you want to test run on GPU, you can set a environment variable as follows:
export SCALA_TEST_ON_GPU=1
```
## Clean up
Clean up for Maven package is simple, you can run the pre-configed `Makefile` as:
Clean up for Maven package is simple:
```Bash
make javaclean
mvn clean
```

## Convert to Eclipse project (Optional)
You can convert the maven project to the eclipse one by running the following command:
```
mvn eclipse:eclipse
```

## Q & A
Expand All @@ -87,4 +95,4 @@ sudo apt install libopencv-imgcodecs3.4
Is there any other version available?

You can find nightly release version from [here](https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~~1.5.0-SNAPSHOT~~).
Please keep the same version in the Makefile or [above version](https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~~~~) to run this demo.
Please keep the same version in the pom file or [other versions in here](https://repository.apache.org/#nexus-search;gav~org.apache.mxnet~~~~) to run this demo.
38 changes: 31 additions & 7 deletions scala-package/mxnet-demo/java-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<version>1.0-SNAPSHOT</version>
<name>MXNet Java Demo</name>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mxnet.version>[1.5.0-SNAPSHOT, )</mxnet.version>
<mxnet.scalaprofile>2.11</mxnet.scalaprofile>
</properties>

<profiles>
<profile>
<id>ci-nightly</id>
Expand All @@ -21,7 +28,30 @@
<mxnet.version>[1.5.0-SNAPSHOT, )</mxnet.version>
</properties>
</profile>
</profiles>
<profile>
<id>osx-x86_64</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<mxnet.profile>osx-x86_64-cpu</mxnet.profile>
</properties>
</profile>
<profile>
<id>linux-x86_64</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<properties>
<mxnet.profile>linux-x86_64-cpu</mxnet.profile>
</properties>
</profile>
</profiles>

<repositories>
<repository>
Expand All @@ -30,12 +60,6 @@
</repository>
</repositories>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<mxnet.version>[1.5.0-SNAPSHOT, )</mxnet.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.mxnet</groupId>
Expand Down
56 changes: 0 additions & 56 deletions scala-package/mxnet-demo/scala-demo/Makefile

This file was deleted.

21 changes: 11 additions & 10 deletions scala-package/mxnet-demo/scala-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# MXNet Scala Sample Project
This is an project created to use Maven-published Scala package with two Scala examples.
## Setup
User are required to use `mvn package` to build the package,
You are required to use maven to build the package, by running the following:
```
mvn package
```
This command will pick the default values specified in the pom file.

Note: If you are planning to use GPU, please add `-Dmxnet.profile=linux-x86_64-gpu`

### Use customized version set
which are shown below:
```Bash
export SCALA_VERSION_PROFILE=2.11 SCALA_VERSION=2.11.8
Expand All @@ -14,13 +22,6 @@ These environment variable (`SCALA_PKG_PROFILE`, `SCALA_VERSION_PROFILE`, `SCALA
should be set before executing the line above.

To obtain the most recent MXNet version, please click [here](https://mvnrepository.com/search?q=org.apache.mxnet)

You can also use the `Makefile` as an alternative to do the same thing. Simply do the following:
```Bash
make scalademo
```
This will load the default parameter for all the environment variable.
If you want to run with GPU on Linux, just simply add `USE_CUDA=1` when you run the make file

## Run
### Hello World
Expand Down Expand Up @@ -54,9 +55,9 @@ If you want to test run on GPU, you can set a environment variable as follows:
export SCALA_TEST_ON_GPU=1
```
## Clean up
Clean up for Maven package is simple, you can run the pre-configed `Makefile` as:
To clean up a Maven package, run the following:
```Bash
make scalaclean
mvn clean
```

## Q & A
Expand Down
25 changes: 25 additions & 0 deletions scala-package/mxnet-demo/scala-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,35 @@
<mxnet.version>[1.5.0-SNAPSHOT, )</mxnet.version>
</properties>
</profile>
<profile>
<id>osx-x86_64</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<mxnet.profile>osx-x86_64-cpu</mxnet.profile>
</properties>
</profile>
<profile>
<id>linux-x86_64</id>
<activation>
<os>
<family>unix</family>
<name>Linux</name>
</os>
</activation>
<properties>
<mxnet.profile>linux-x86_64-cpu</mxnet.profile>
</properties>
</profile>
</profiles>

<properties>
<mxnet.scalaprofile>2.11</mxnet.scalaprofile>
<mxnet.version>[1.3.1, )</mxnet.version>
<scala.version>2.11.8</scala.version>
</properties>

<dependencies>
Expand Down

0 comments on commit c5c1dc7

Please sign in to comment.