From c5c1dc7c7b64ad0495ad77f1516b4816aebcd9f3 Mon Sep 17 00:00:00 2001 From: Lanking Date: Mon, 28 Jan 2019 13:34:40 -0800 Subject: [PATCH] [MXNET-1232] fix demo and add Eclipse support (#13979) * fix demo and add Eclipse support * fix on docs * fix typo * Update docs/install/java_setup.md Co-Authored-By: lanking520 * add fixes in docs --- ci/docker/runtime_functions.sh | 4 +- docs/install/java_setup.md | 13 ++++- scala-package/mxnet-demo/java-demo/Makefile | 52 ----------------- scala-package/mxnet-demo/java-demo/README.md | 30 ++++++---- scala-package/mxnet-demo/java-demo/pom.xml | 38 ++++++++++--- scala-package/mxnet-demo/scala-demo/Makefile | 56 ------------------- scala-package/mxnet-demo/scala-demo/README.md | 21 +++---- scala-package/mxnet-demo/scala-demo/pom.xml | 25 +++++++++ 8 files changed, 98 insertions(+), 141 deletions(-) delete mode 100644 scala-package/mxnet-demo/java-demo/Makefile delete mode 100644 scala-package/mxnet-demo/scala-demo/Makefile diff --git a/ci/docker/runtime_functions.sh b/ci/docker/runtime_functions.sh index f7631374a638..d97da64d9735 100755 --- a/ci/docker/runtime_functions.sh +++ b/ci/docker/runtime_functions.sh @@ -1241,7 +1241,7 @@ 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 } @@ -1249,7 +1249,7 @@ nightly_java_demo_test_cpu() { 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 } diff --git a/docs/install/java_setup.md b/docs/install/java_setup.md index 0075e9205880..ea4bb50329e8 100644 --- a/docs/install/java_setup.md +++ b/docs/install/java_setup.md @@ -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).
+### 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: @@ -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.
diff --git a/scala-package/mxnet-demo/java-demo/Makefile b/scala-package/mxnet-demo/java-demo/Makefile deleted file mode 100644 index 3811d75d2091..000000000000 --- a/scala-package/mxnet-demo/java-demo/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -SCALA_VERSION_PROFILE := 2.11 - -ifeq ($(OS),Windows_NT) - UNAME_S := Windows -else - UNAME_S := $(shell uname -s) -endif - -ifeq ($(UNAME_S), Windows) - # TODO: currently scala package does not support windows - SCALA_PKG_PROFILE := windows -else - ifeq ($(UNAME_S), Darwin) - SCALA_PKG_PROFILE := osx-x86_64-cpu - else - SCALA_PKG_PROFILE := linux-x86_64 - ifeq ($(USE_CUDA), 1) - SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu - else - SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-cpu - endif - endif -endif - -javademo: - (mvn install -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE)) - -java_ci_demo: - (mvn -Pci-nightly install -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE)) - -javaclean: - (mvn clean -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE)) diff --git a/scala-package/mxnet-demo/java-demo/README.md b/scala-package/mxnet-demo/java-demo/README.md index 73e9284a96ef..5dfbf14e8df2 100644 --- a/scala-package/mxnet-demo/java-demo/README.md +++ b/scala-package/mxnet-demo/java-demo/README.md @@ -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= @@ -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 @@ -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. \ No newline at end of file diff --git a/scala-package/mxnet-demo/java-demo/pom.xml b/scala-package/mxnet-demo/java-demo/pom.xml index b7502a66c511..05d04b9e6c14 100644 --- a/scala-package/mxnet-demo/java-demo/pom.xml +++ b/scala-package/mxnet-demo/java-demo/pom.xml @@ -8,6 +8,13 @@ 1.0-SNAPSHOT MXNet Java Demo + + 1.8 + 1.8 + [1.5.0-SNAPSHOT, ) + 2.11 + + ci-nightly @@ -21,7 +28,30 @@ [1.5.0-SNAPSHOT, ) - + + osx-x86_64 + + + mac + + + + osx-x86_64-cpu + + + + linux-x86_64 + + + unix + Linux + + + + linux-x86_64-cpu + + + @@ -30,12 +60,6 @@ - - 1.8 - 1.8 - [1.5.0-SNAPSHOT, ) - - org.apache.mxnet diff --git a/scala-package/mxnet-demo/scala-demo/Makefile b/scala-package/mxnet-demo/scala-demo/Makefile deleted file mode 100644 index 9f7f2840e9a4..000000000000 --- a/scala-package/mxnet-demo/scala-demo/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -SCALA_VERSION_PROFILE := 2.11 -SCALA_VERSION := 2.11.8 - -ifeq ($(OS),Windows_NT) - UNAME_S := Windows -else - UNAME_S := $(shell uname -s) -endif - -ifeq ($(UNAME_S), Windows) - # TODO: currently scala package does not support windows - SCALA_PKG_PROFILE := windows -else - ifeq ($(UNAME_S), Darwin) - SCALA_PKG_PROFILE := osx-x86_64-cpu - else - SCALA_PKG_PROFILE := linux-x86_64 - ifeq ($(USE_CUDA), 1) - SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu - else - SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-cpu - endif - endif -endif - -scalademo: - (mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \ - -Dscala.version=$(SCALA_VERSION)) - -scala_ci_demo: - (mvn -Pci-nightly package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \ - -Dscala.version=$(SCALA_VERSION)) - -scalaclean: - (mvn clean -Dmxnet.profile=$(SCALA_PKG_PROFILE) \ - -Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \ - -Dscala.version=$(SCALA_VERSION)) \ No newline at end of file diff --git a/scala-package/mxnet-demo/scala-demo/README.md b/scala-package/mxnet-demo/scala-demo/README.md index 1cc5a6d42b95..b994a196b1f6 100644 --- a/scala-package/mxnet-demo/scala-demo/README.md +++ b/scala-package/mxnet-demo/scala-demo/README.md @@ -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 @@ -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 @@ -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 diff --git a/scala-package/mxnet-demo/scala-demo/pom.xml b/scala-package/mxnet-demo/scala-demo/pom.xml index 1d89f97655d2..37d60d133c31 100644 --- a/scala-package/mxnet-demo/scala-demo/pom.xml +++ b/scala-package/mxnet-demo/scala-demo/pom.xml @@ -22,10 +22,35 @@ [1.5.0-SNAPSHOT, ) + + osx-x86_64 + + + mac + + + + osx-x86_64-cpu + + + + linux-x86_64 + + + unix + Linux + + + + linux-x86_64-cpu + + + 2.11 [1.3.1, ) + 2.11.8