diff --git a/.travis.yml b/.travis.yml
index 1620f127849..a99bc287d87 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -729,6 +729,10 @@ matrix:
env: PROJ=caffe OS=linux-x86_64 EXT=-gpu
install: true
script: ./ci/install-travis.sh
+ - os: linux
+ env: PROJ=mxnet OS=linux-x86_64 EXT=-gpu
+ install: true
+ script: ./ci/install-travis.sh
- os: linux
env: PROJ=tensorflow OS=linux-x86_64 EXT=-gpu
install: true
@@ -744,6 +748,11 @@ matrix:
env: PROJ=caffe OS=macosx-x86_64 EXT=-gpu
install: true
script: ./ci/install-travis.sh
+ - os: osx
+ osx_image: xcode8.3
+ env: PROJ=mxnet OS=macosx-x86_64 EXT=-gpu
+ install: true
+ script: ./ci/install-travis.sh
- os: osx
osx_image: xcode8.3
env: PROJ=tensorflow OS=macosx-x86_64 EXT=-gpu
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d222e251d3f..dc33ab95927 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
+ * Add CUDA-enabled build for MXNet via `-gpu` extension ([pull #609](https://github.com/bytedeco/javacpp-presets/pull/609))
* Prevent MKL-DNN from compiling code with `-march=native` ([pull #618](https://github.com/bytedeco/javacpp-presets/pull/618))
* Add an RPATH to `libmkldnn.so.0` to avoid loading issues on Linux ([issue deeplearning4j/deeplearning4j#6366](https://github.com/deeplearning4j/deeplearning4j/issues/6366))
* Fix logic in `tensorflow.Tensor.createIndexer()` to support scalar tensors
diff --git a/mxnet/LICENSE b/mxnet/LICENSE
index 01dfcf46792..a8b57e58376 100644
--- a/mxnet/LICENSE
+++ b/mxnet/LICENSE
@@ -201,7 +201,7 @@
See the License for the specific language governing permissions and
limitations under the License.
- =======================================================================
+ ======================================================================================
Apache MXNET (incubating) Subcomponents:
The Apache MXNET (incubating) project contains subcomponents with separate copyright
@@ -209,9 +209,9 @@
subcomponents is subject to the terms and conditions of the following
licenses.
- ========================================================================
+ =======================================================================================
Apache-2.0 licenses
- ========================================================================
+ =======================================================================================
The following components are provided under an Apache 2.0 license.
@@ -219,28 +219,33 @@
2. MXNet rcnn - For details, see, example/rcnn/LICENSE
3. scala-package - For details, see, scala-package/LICENSE
4. Warp-CTC - For details, see, src/operator/contrib/ctc_include/LICENSE
- 5. dlpack - For details, see, dlpack/LICENSE
- 6. dmlc-core - For details, see, dmlc-core/LICENSE
- 7. mshadow - For details, see, mshadow/LICENSE
- 8. nnvm/dmlc-core - For details, see, nnvm/dmlc-core/LICENSE
- 9. nnvm - For details, see, nnvm/LICENSE
- 10. nnvm-fusion - For details, see, nnvm/plugin/nnvm-fusion/LICENSE
- 11. ps-lite - For details, see, ps-lite/LICENSE
-
- ========================================================================
+ 5. 3rdparty/dlpack - For details, see, 3rdparty/dlpack/LICENSE
+ 6. 3rdparty/dmlc-core - For details, see, 3rdparty/dmlc-core/LICENSE
+ 7. 3rdparty/mshadow - For details, see, 3rdparty/mshadow/LICENSE
+ 8. 3rdparty/tvm - For details, see, 3rdparty/tvm/LICENSE
+ 9. 3rdparty/tvm/dmlc-core - For details, see, 3rdparty/tvm/dmlc-core/LICENSE
+ 10. 3rdparty/tvm/nnvm - For details, see, 3rdparty/tvm/nnvm/LICENSE
+ 11. 3rdparty/ps-lite - For details, see, 3rdparty/ps-lite/LICENSE
+ 12. 3rdparty/mkldnn - For details, see, 3rdparty/mkldnn/LICENSE
+ 13. googlemock scripts/generator - For details, see, 3rdparty/googletest/googlemock/scripts/generator/LICENSE
+
+
+ =======================================================================================
MIT licenses
- ========================================================================
+ =======================================================================================
1. Fast R-CNN - For details, see example/rcnn/LICENSE
2. Faster R-CNN - For details, see example/rcnn/LICENSE
3. tree_lstm - For details, see example/gluon/tree_lstm/LICENSE
+ 4. OpenMP - For details, see 3rdparty/openmp/LICENSE.txt
+ 5. HalideIR - For details, see nnvm/tvm/HalideIR/LICENSE
- ========================================================================
+ =======================================================================================
NVIDIA Licenses
- ========================================================================
+ =======================================================================================
- 1. Warp-CTC
+ 1. Moderngpu
For details, see, src/operator/contrib/ctc_include/contrib/moderngpu/LICENSE
/******************************************************************************
@@ -269,7 +274,7 @@
******************************************************************************/
2. CUB Library
- For details, see, cub/LICENSE.TXT
+ For details, see, 3rdparty/cub/LICENSE.TXT
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -293,10 +298,9 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- ========================================================================
+ =======================================================================================
Other Licenses
- ========================================================================
+ =======================================================================================
1. Caffe
For details, see, example/rcnn/LICENSE
@@ -329,6 +333,7 @@
or otherwise, the contributor releases their content to the
license and copyright terms herein.
+ =======================================================================================
2. MS COCO API
For details, see, example/rcnn/LICENSE
@@ -357,3 +362,201 @@
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
+ =======================================================================================
+
+ 3. Sphinx JavaScript utilties for the full-text search
+ For details, see, docs/_static/searchtools_custom.js
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ =======================================================================================
+
+ 4. FindCrypto.cmake
+ For details, see, 3rdparty/dmlc-core/cmake/Modules/FindCrypto.cmake,
+ Redistribution and use is allowed according to the terms of the BSD license.
+
+ =======================================================================================
+
+ 5. Googlemock
+ For details, see, 3rdparty/googletest/googlemock/LICENSE
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ =======================================================================================
+
+ 6. Googletest
+ For details, see, 3rdparty/googletest/googletest/LICENSE
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ =======================================================================================
+
+ 7. OpenMP Testsuite
+ For details, see, 3rdparty/openmp/testsuite/LICENSE
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ o Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ o Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ o Neither the name of the University of Houston System nor the names of its
+ contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ =======================================================================================
+
+ 8. Semaphore implementation in blockingconcurrentqueue.h
+ This file uses a semaphore implementation under the terms of its separate zlib license.
+ For details, see, 3rdparty/dmlc-core/include/dmlc/blockingconcurrentqueue.h
+
+ =======================================================================================
+
+ 9. blockingconcurrentqueue.h
+ This file is Distributed under the terms of the simplified BSD license.
+ For details, see, 3rdparty/dmlc-core/include/dmlc/blockingconcurrentqueue.h
+
+ =======================================================================================
+
+ 10. concurrentqueue.h
+ This file is Distributed under the terms of the simplified BSD license.
+ For details, see, 3rdparty/dmlc-core/include/dmlc/concurrentqueue.h
+
+ =======================================================================================
+
+ 11. ONNX Export module
+ For details, see, python/mxnet/contrib/onnx/_export/LICENSE
+
+ # 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.
+ #
+ # Based on
+ # https://github.com/NVIDIA/mxnet_to_onnx/blob/master/mx2onnx_converter/#
+ # Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or without
+ # modification, are permitted provided that the following conditions
+ # are met:
+ # * Redistributions of source code must retain the above copyright
+ # notice, this list of conditions and the following disclaimer.
+ # * Redistributions in binary form must reproduce the above copyright
+ # notice, this list of conditions and the following disclaimer in the
+ # documentation and/or other materials provided with the distribution.
+ # * Neither the name of NVIDIA CORPORATION nor the names of its
+ # contributors may be used to endorse or promote products derived
+ # from this software without specific prior written permission.
+ #
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
diff --git a/mxnet/README.md b/mxnet/README.md
index b62df1c0208..19e33f22ba1 100644
--- a/mxnet/README.md
+++ b/mxnet/README.md
@@ -46,6 +46,35 @@ We can use [Maven 3](http://maven.apache.org/) to download and install automatic
mxnet-platform
1.3.0-1.4.3-SNAPSHOT
+
+
+
+ org.bytedeco.javacpp-presets
+ mxnet
+ 1.3.0-1.4.3-SNAPSHOT
+ linux-x86_64-gpu
+
+
+ org.bytedeco.javacpp-presets
+ mxnet
+ 1.3.0-1.4.3-SNAPSHOT
+ macosx-x86_64-gpu
+
+
+
+
+ org.bytedeco.javacpp-presets
+ cuda
+ 10.0-7.3-1.4.3-SNAPSHOT
+ linux-x86_64-redist
+
+
+ org.bytedeco.javacpp-presets
+ cuda
+ 10.0-7.3-1.4.3-SNAPSHOT
+ macosx-x86_64-redist
+
+
```
diff --git a/mxnet/cppbuild.sh b/mxnet/cppbuild.sh
index 030b57823df..972e1baf9c8 100755
--- a/mxnet/cppbuild.sh
+++ b/mxnet/cppbuild.sh
@@ -7,9 +7,20 @@ if [[ -z "$PLATFORM" ]]; then
exit
fi
-export ADD_CFLAGS=
+export ADD_CFLAGS="-DMXNET_USE_LAPACK=1"
export ADD_LDFLAGS=
export USE_OPENMP=1
+export CUDA_ARCH=-arch=sm_30
+export USE_CUDA=0
+export USE_CUDNN=0
+export USE_CUDA_PATH=
+if [[ "$EXTENSION" == *gpu ]]; then
+ export ADD_CFLAGS="$ADD_CFLAGS -DMXNET_USE_CUDA=1"
+ export USE_CUDA=1
+ export USE_CUDNN=1
+ export USE_CUDA_PATH="/usr/local/cuda"
+fi
+
case $PLATFORM in
linux-x86)
export CC="gcc -m32"
@@ -19,13 +30,16 @@ case $PLATFORM in
linux-x86_64)
export CC="gcc -m64"
export CXX="g++ -m64"
+ if which g++-6 &> /dev/null; then
+ export CC="gcc-6 -m64"
+ export CXX="g++-6 -m64"
+ fi
export BLAS="openblas"
;;
macosx-*)
export CC="clang"
export CXX="clang++"
export BLAS="openblas"
- export ADD_CFLAGS="-Dthread_local="
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
@@ -36,8 +50,8 @@ esac
MXNET_VERSION=1.3.0
download http://apache.org/dist/incubator/mxnet/$MXNET_VERSION/apache-mxnet-src-$MXNET_VERSION-incubating.tar.gz apache-mxnet-src-$MXNET_VERSION-incubating.tar.gz
-mkdir -p $PLATFORM
-cd $PLATFORM
+mkdir -p "$PLATFORM$EXTENSION"
+cd "$PLATFORM$EXTENSION"
INSTALL_PATH=`pwd`
OPENCV_PATH="$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/"
@@ -70,7 +84,7 @@ export LIBRARY_PATH="$OPENBLAS_PATH/:$OPENBLAS_PATH/lib/:$OPENCV_PATH/:$OPENCV_P
sed -i="" 's/$(shell pkg-config --cflags opencv)//' Makefile
sed -i="" 's/$(shell pkg-config --libs opencv)/-lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core/' Makefile
-make -j $MAKEJ CC="$CC" CXX="$CXX" USE_BLAS="$BLAS" USE_OPENMP="$USE_OPENMP" USE_F16C=0 ADD_CFLAGS="-DMXNET_USE_LAPACK=1 $ADD_CFLAGS" ADD_LDFLAGS="$ADD_LDFLAGS" lib/libmxnet.a lib/libmxnet.so
+make -j $MAKEJ CC="$CC" CXX="$CXX" USE_BLAS="$BLAS" USE_OPENMP="$USE_OPENMP" CUDA_ARCH="$CUDA_ARCH" USE_CUDA="$USE_CUDA" USE_CUDNN="$USE_CUDNN" USE_CUDA_PATH="$USE_CUDA_PATH" USE_F16C=0 ADD_CFLAGS="$ADD_CFLAGS" ADD_LDFLAGS="$ADD_LDFLAGS" lib/libmxnet.a lib/libmxnet.so
cp -a include lib 3rdparty/dmlc-core/include ..
cp -a 3rdparty/mshadow/mshadow ../include
unset CC
diff --git a/mxnet/pom.xml b/mxnet/pom.xml
index 50acb9067ee..ae4be3a2db2 100644
--- a/mxnet/pom.xml
+++ b/mxnet/pom.xml
@@ -14,10 +14,6 @@
1.3.0-${project.parent.version}
JavaCPP Presets for MXNet
-
- ${javacpp.platform.compiler}
-
-
org.bytedeco.javacpp-presets
@@ -71,16 +67,6 @@
-
-
- platform.root
- ${javacpp.platform.root}
-
-
- platform.compiler
- ${javacpp.platform.oldcompiler}
-
-
${basedir}/../opencv/target/classes/
${basedir}/../openblas/target/classes/
@@ -94,17 +80,17 @@
${basedir}/../openblas/target/classes/org/bytedeco/javacpp/include/
${basedir}/../openblas/src/main/resources/org/bytedeco/javacpp/include/
${basedir}/../openblas/cppbuild/${javacpp.platform}/include/
- ${basedir}/cppbuild/${javacpp.platform}/include/
+ ${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/include/
${basedir}/../opencv/cppbuild/${javacpp.platform}/lib/
${basedir}/../openblas/cppbuild/${javacpp.platform}/lib/
- ${basedir}/cppbuild/${javacpp.platform}/lib/
+ ${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/lib/
${basedir}/../opencv/cppbuild/${javacpp.platform}/bin/
${basedir}/../openblas/cppbuild/${javacpp.platform}/bin/
- ${basedir}/cppbuild/${javacpp.platform}/bin/
+ ${basedir}/cppbuild/${javacpp.platform}${javacpp.platform.extension}/bin/
diff --git a/mxnet/src/main/java/org/bytedeco/javacpp/presets/mxnet.java b/mxnet/src/main/java/org/bytedeco/javacpp/presets/mxnet.java
index 3928f60e5da..3116520e0d3 100644
--- a/mxnet/src/main/java/org/bytedeco/javacpp/presets/mxnet.java
+++ b/mxnet/src/main/java/org/bytedeco/javacpp/presets/mxnet.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Samuel Audet
+ * Copyright (C) 2016-2018 Samuel Audet
*
* Licensed either under the Apache License, Version 2.0, or (at your option)
* under the terms of the GNU General Public License as published by
@@ -22,7 +22,10 @@
package org.bytedeco.javacpp.presets;
+import java.util.List;
+import org.bytedeco.javacpp.ClassProperties;
import org.bytedeco.javacpp.FunctionPointer;
+import org.bytedeco.javacpp.LoadEnabled;
import org.bytedeco.javacpp.Loader;
import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.Cast;
@@ -41,8 +44,39 @@
include = {"mxnet/c_api.h", "mxnet/c_predict_api.h", /*"dmlc/base.h", "dmlc/io.h", "dmlc/logging.h", "dmlc/type_traits.h",
"dmlc/parameter.h", "mshadow/base.h", "mshadow/expression.h", "mshadow/tensor.h", "mxnet/base.h",*/},
link = "mxnet", /*resource = {"include", "lib"},*/ includepath = {"/usr/local/cuda/include/",
- "/System/Library/Frameworks/vecLib.framework/", "/System/Library/Frameworks/Accelerate.framework/"}, linkpath = "/usr/local/cuda/lib/") })
-public class mxnet implements InfoMapper {
+ "/System/Library/Frameworks/vecLib.framework/", "/System/Library/Frameworks/Accelerate.framework/"}, linkpath = "/usr/local/cuda/lib/"),
+ @Platform(value = {"linux-x86_64", "macosx-x86_64"}, define = {"DMLC_USE_CXX11 1", "MSHADOW_USE_CBLAS 1", "MSHADOW_IN_CXX11 1", "MSHADOW_USE_CUDA 1"}, extension = "-gpu") })
+public class mxnet implements LoadEnabled, InfoMapper {
+
+ @Override public void init(ClassProperties properties) {
+ String platform = properties.getProperty("platform");
+ String extension = properties.getProperty("platform.extension");
+ List preloads = properties.get("platform.preload");
+
+ // Only apply this at load time since we don't want to copy the CUDA libraries here
+ if (!Loader.isLoadLibraries() || extension == null || !extension.equals("-gpu")) {
+ return;
+ }
+ int i = 0;
+ String[] libs = {"cudart", "cublas", "cufft", "curand", "cusolver", "cudnn", "nvrtc"};
+ for (String lib : libs) {
+ switch (platform) {
+ case "linux-x86_64":
+ case "macosx-x86_64":
+ lib += lib.equals("cudnn") ? "@.7" : "@.10.0";
+ break;
+ case "windows-x86_64":
+ lib += lib.equals("cudnn") ? "64_7" : "64_100";
+ break;
+ default:
+ continue; // no CUDA
+ }
+ if (!preloads.contains(lib)) {
+ preloads.add(i++, lib);
+ }
+ }
+ }
+
public void map(InfoMap infoMap) {
infoMap.put(new Info("MXNET_EXTERN_C", "MXNET_DLL").cppTypes().annotations())
.put(new Info("NDArrayHandle").valueTypes("NDArrayHandle").pointerTypes("PointerPointer", "@Cast(\"NDArrayHandle*\") @ByPtrPtr NDArrayHandle"))