The goal here is to build mxnet.io on Windows. This was tested on Windows 10. Overall, the procedure is to compile mxnet to generate an up-to-date libmxnet.dll
. Once we have that, we will build and install the R package containing all dependent libraries, including the newly-built libmxnet.dll
.
This guide was adapted from the primary setup documentation http://mxnet.io/get_started/setup.html which seems out-of-date.
- Visual Studio 2013 (tested with Community Edition)
- cmake - from here
- OpenBLAS v0.2.19 - win64 binary package called
OpenBLAS-v0.2.19-Win64-int32.zip
from here - OpenCV v3.1.0 -
opencv-3.1.0.exe
from here - CUDA v8 -
cuda_8.0.44_win10.exe
from here - CuDNN v5.1 -
cudnn-8.0-windows10-x64-v5.1.zip
from here. Note you need to register with nVidia to download. - R and RTools - tested R v3.3.2 (
R-3.3.2-win.exe
from here) and RTools v3.4 (Rtools34.exe
from here)
Assume that packages will be saved to C:\Development\
. Feel free to choose another place, but update the below paths accordingly.
-
Install Visual Studio 2013
-
Unzip cmake to
C:\Development\cmake\
. You should now have:C:\Development\cmake\bin\cmake-gui.exe
-
Unzip OpenBlas to
C:\Development\OpenBLAS-v0.2.19-Win64-int32\
. You should now have the following directories:C:\Development\OpenBLAS-v0.2.19-Win64-int32\bin C:\Development\OpenBLAS-v0.2.19-Win64-int32\lib C:\Development\OpenBLAS-v0.2.19-Win64-int32\include
-
Unzip OpenCV to
C:\Development\opencv-3.1.0\
. You should now have the following directories:C:\Development\opencv-3.1.0\build C:\Development\opencv-3.1.0\sources
-
Run the CUDA v8 installation. You should now have the following directories:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
-
Unzip CuDNN v5.1 to
C:\Development\cudnn-8.0-windows10-x64-v5.1\
. You should now have directories called:C:\Development\cudnn-8.0-windows10-x64-v5.1\cuda\bin C:\Development\cudnn-8.0-windows10-x64-v5.1\cuda\include C:\Development\cudnn-8.0-windows10-x64-v5.1\cuda\lib
-
Install R and RTools
To build mxnet, we'll need to use cmake to configure an appropriate Visual Studio solution (.sln
) file. Once that is complete, we can open the solution file and build a release version of mxnet in Visual Studio 2013.
-
Clone the latest mxnet source code to
C:\Development\mxnet\
usinggit clone --recursive https://github.com/dmlc/mxnet.git
to ensure the submodules are fetched. You should have at least the following directories and they should not be empty:C:\Development\mxnet\cmake C:\Development\mxnet\R-package C:\Development\mxnet\dmlc-core C:\Development\mxnet\mshadow C:\Development\mxnet\ps-lite
-
Run the cmake GUI (
cmake-gui.exe
from above)-
In the
Where is the source code:
field, enter the mxnet source code directory which should beC:\Development\mxnet\
. -
In the
Where to build the binaries:
field, enterC:\Development\mxnet\build\
. -
Make sure "Grouped" is checked, then click the configure button towards the bottom of the GUI.
-
A dialog will pop up and you should change the generator to be
Visual Studio 12 2013 Win64
, then click Finish. -
After running for a bit, there will be some red lines in the cmake interface that need to be fixed. The general procedure is to update the RED lines and click configure again. Here are somethings that need to be checked/fixed:
- Make sure that under the USE, all of
USE_CUDA
,USE_CUDNN
,USE_MXNET_LIBNAMING
,USE_OPENCV
, andUSE_OPENMP
are all checked and the remainder are unchecked. - OpenCV_DIR and OpenCV_CONFIG_PATH should be
C:/Development/opencv-3.1.0/build
. - CUDNN_INCLUDE should be
C:/Development/cudnn-8.0-windows10-x64-v5.1/cuda/include
. - CUDNN_LIBRARY should be
C:/Development/cudnn-8.0-windows10-x64-v5.1/cuda/lib/x64/cudnn.lib
- CUDA_TOOLKIT_ROOT_DIR should be
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0
- OpenBLAS_INCLUDE_DIR should be
C:/Development/OpenBLAS-v0.2.19/include
- OpenBLAS_LIB should be
C:/Development/OpenBLAS-v0.2.19/lib/libopenblas.dll.a
- Make sure that under the USE, all of
-
Once the last Configure run completes with
Configuring done
in th log window, click Generate. -
The log window should say
Generating done
.
-
At this point we can proceed to build mxnet libraries in Visual studio.
-
Go to
C:\Development\mxnet\build\
and double-click to open themxnet.sln
file. This will open Visual Studio 2013. -
Make sure the toggles on the toolbar read
Release
andx64
, then click to theBuild > Build Solution
. -
Wait for the compilation and linking procedures to finish (took approximately 15 minutes on my laptop). When complete you should have the following file available:
C:\Development\mxnet\build\Release\libmxnet.dll
The mxnet source code contains a directory called C:\Development\mxnet\R-package\
. This is the base directory used to compile and build an R package which can then be installed on any windows machine. This package will contain all necessary DLLs to run the mxnet libraries, so many DLLs will need to be copied to the right place.
Some of the DLLs will be the ones installed already (i.e. from CUDA, CuDNN, OpenBLAS, etc.) but there are some that we will copy from the primary mxnet R package that doesn't contain up-to-date GPU support.
-
Go to the main release page and download the latest windows build release for GPU:
20160531_win10_x64_gpu.7z
. -
Unzip this to
C:\Development\20160531_win10_x64_gpu\
and you should have the following directories:C:\Development\20160531_win10_x64_gpu\3rdparty C:\Development\20160531_win10_x64_gpu\include
-
Go to
C:\Development\mxnet\R-package\
and make the following directories:C:\Development\mxnet\R-package\inst\include
C:\Development\mxnet\R-package\inst\libs\x64\ -
Copy the three directories named
dmlc
,mshadow
,mxnet
inC:\Development\20160531_win10_x64_gpu\include
toC:\Development\mxnet\R-package\inst\include\
. -
Copy
C:\Development\20160531_win10_x64_gpu\3rdparty\gnuwin\unzip32.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Development\20160531_win10_x64_gpu\3rdparty\openblas\bin
directory, copylibgcc_s_seh-1.dll
,libgfortran-3.dll
, andlibquadmath-0.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Users\flam\Downloads\20160531_win10_x64_gpu\3rdparty\vc\
directory, copyvcomp120.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Development\OpenBLAS-v0.2.19-Win64-int32\bin
directory, copylibopenblas.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin
directory, copycublas64_80.dll
,cudart64_80.dll
,curand64_80.dll
,nvrtc64_80.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Development\cudnn-8.0-windows10-x64-v5.1\cuda\bin
directory, copycudnn64_5.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
From the
C:\Development\opencv-3.1.0\build\x64\vc12\bin
directory, copyopencv_world310.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. -
Finally copy the locally built mxnet library
C:\Development\mxnet\build\Release\libmxnet.dll
toC:\Development\mxnet\R-package\inst\libs\x64\
. At this point there should be 13 dlls in that directory.
We're now ready to build and install the R package.
-
Open up a command prompt and cd to
C:\Development\mxnet\
. -
If your R.exe isn't on the path, add it or just reference it directly and run:
"C:\Program Files\R\R-3.3.2\bin\R.exe" CMD INSTALL --build --no-multiarch R-package
-
Once it has completed building the package, you should have a file called
C:\Development\mxnet\mxnet_0.7.zip
and the following message:packaged installation of 'mxnet' as mxnet_0.7.zip
- DONE (mxnet)
That mxnet_0.7.zip can now be distributed to any other Windows nodes that need the mxnet R package by just using install.packages()
and referencing the mxnet_0.7.zip as the local package.
If you run require(mxnet)
, this should load properly, but you can also run a more complex test using instructions from the main page: http://mxnet.io/tutorials/r/mnistCompetition.html.
I am very appreciate with your install tutorial. and...
I have two question about making the 'libmxnet.dll' in order to construct GPU usable environment.
Because of my limited computer hardware and software background, I would like to ask some question to you.
Could you mind if you comment my problems?
I am wondering whether you regard 'this source file' as 'https://github.com/dmlc/mxnet'
When I try to click 'Clone or download' and downloading done, some folders(dmlc-core, mshadow, ps-lite) empty.
So I have to download this inner file from
https://github.com/dmlc/dmlc-core/tree/39007ac49b6087339dc3104324cb4e0de47f1c5f
https://github.com/dmlc/mshadow/tree/f67e112dcfe7e054cb7866d289d8c826808bd359
https://github.com/dmlc/ps-lite/tree/4a060e4e8aa40c3a931a0f8af9211279e012f8a2
and combine previous mxnet folder.
I wonder if I'm doing well
When I tried to check your list that need to be fixed, cmake showed not finding about python 2.x, python 3.x location.
I ignored these issues, and made libmxnet.dll file finally.
Is it okay ignore these python issues?