Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build MXNet under windows #309

Merged
merged 18 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/target/
/opencv/cppbuild/
/opencv/target/
/openblas/cppbuild/
/openblas/target/
/ffmpeg/cppbuild/
/ffmpeg/target/
/flycapture/cppbuild/
Expand Down Expand Up @@ -36,6 +38,8 @@
/mxnet/target/
/tensorflow/cppbuild/
/tensorflow/target/
/hdf5/cppbuild/
/hdf5/target/

# Mac
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion hdf5/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ case $PLATFORM in
# Installers available at: https://support.hdfgroup.org/HDF5/release/obtain5110.html
windows-*)
if [[ ! -d "/C/Program Files/HDF_Group/HDF5/1.10.0/" ]]; then
echo "Please install HDF5 under the default installation directory"
echo "Please install HDF5 (https://support.hdfgroup.org/HDF5/release/obtain5110.html) under the default installation directory (C:\Program Files\HDF_Group\HDF5\1.10.0\)"
exit 1
fi
;;
Expand Down
37 changes: 37 additions & 0 deletions mxnet/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,43 @@ case $PLATFORM in
export CXX="clang-omp++"
export BLAS="apple"
;;
windows-*)
return 0
mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`

# clone mxnet and its submodules
git clone https://github.com/dmlc/mxnet.git --recursive
cd mxnet

# checkout a stable commit
git checkout a5aeb0c43028f41863a8148eb3ecf30e90caad1e

# configure the build
export OPENCV_DIR="$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/" # override the system variable
USE_X="-DUSE_CUDA=OFF -DUSE_CUDNN=OFF -DUSE_OPENCV=ON"
OPENCV="-DOpenCV_DIR=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/ -DOpenCV_CONFIG_PATH=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/ -DOpenCV_3RDPARTY_LIB_DIR_DBG=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/lib -DOpenCV_3RDPARTY_LIB_DIR_OPT=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/lib -DOpenCV_LIB_DIR_DBG=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM/lib -DOpenCV_LIB_DIR_OPT=$INSTALL_PATH/../../../opencv/cppbuild/$PLATFORM//lib"
OPENBLAS="-DOpenBLAS_INCLUDE_DIR=$INSTALL_PATH/../../../openblas/cppbuild/$PLATFORM/include/ -DOpenBLAS_LIB=$INSTALL_PATH/../../../openblas/cppbuild/$PLATFORM/lib/libopenblas.dll.a"
"$CMAKE" -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=.. $USE_X $OPENBLAS $OPENCV

# build the project
MSBuild.exe ALL_BUILD.vcxproj //p:Configuration=Release

# copy include files
mkdir ../include
cp -a include/mxnet dmlc-core/include/dmlc mshadow/mshadow ../include

# copy binary files
mkdir ../bin
cp -a Release/* ../bin

# copy library files
mkdir ../lib
cp -a Release/* ../lib
cd ../..
return 0
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
return 0
Expand Down
19 changes: 14 additions & 5 deletions mxnet/src/main/java/org/bytedeco/javacpp/presets/mxnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,20 @@
* @author Samuel Audet
*/
@Properties(inherit = {openblas.class, opencv_highgui.class}, target = "org.bytedeco.javacpp.mxnet", value = {
@Platform(value = {"linux-x86", "macosx"}, compiler = "cpp11", define = {"DMLC_USE_CXX11 1", "MSHADOW_USE_CBLAS 1", "MSHADOW_IN_CXX11 1"},
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", includepath = {"/usr/local/cuda/include/",
"/System/Library/Frameworks/vecLib.framework/", "/System/Library/Frameworks/Accelerate.framework/"}, linkpath = "/usr/local/cuda/lib/") })
@Platform(value = {"linux-x86", "macosx"},
compiler = "cpp11",
define = {"DMLC_USE_CXX11 1", "MSHADOW_USE_CBLAS 1", "MSHADOW_IN_CXX11 1"},
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",
includepath = {"/usr/local/cuda/include/", "/System/Library/Frameworks/vecLib.framework/", "/System/Library/Frameworks/Accelerate.framework/"},
linkpath = "/usr/local/cuda/lib/"
),
@Platform(value = {"windows"},
include = {"mxnet/c_api.h", "mxnet/c_predict_api.h" },
link = { "libmxnet" }
)
})
public class mxnet implements InfoMapper {
public void map(InfoMap infoMap) {
infoMap.put(new Info("MXNET_EXTERN_C", "MXNET_DLL").cppTypes().annotations())
Expand Down
7 changes: 7 additions & 0 deletions openblas/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,11 @@ esac
make -j $MAKEJ libs netlib shared "CROSS_SUFFIX=$CROSS_SUFFIX" "CC=$CC" "FC=$FC" "HOSTCC=$HOSTCC" BINARY=$BINARY TARGET=$TARGET COMMON_PROF=
make install "PREFIX=$INSTALL_PATH"

# create .lib files which can be used in other builds
case $PLATFORM in
windows-*)
cp ../lib/libopenblas.dll.a ../lib/openblas.lib
;;
esac

cd ../..
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<version>1.5.0</version>
<executions>
<execution>
<id>javacpp.cppbuild.install</id>
Expand Down