On Windows, you can download and install the prebuilt MXNet package, or download, build, and install MXNet yourself.
You can either use a prebuilt binary package or build from source to build the MXNet shared library - libmxnet.dll
.
MXNet provides a prebuilt package for Windows. The prebuilt package includes the MXNet library, all of the dependent third-party libraries, a sample C++ solution for Visual Studio, and the Python installation script. To install the prebuilt package:
D:\MXNet
.setupenv.cmd
. This sets up all of the environment variables required by MXNet. This produces a library called libmxnet.dll
.
To build and install MXNet yourself, you need the following dependencies. Install the required dependencies:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
folder to a different location.C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2013 CTP
folder (or the folder where you extracted the zip archive) to the C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
folder, and overwrite all existing files.OpenCV_DIR
to point to the OpenCV build directory
.OpenBLAS_HOME
to point to the OpenBLAS
directory that contains the include
and lib
directories. Typically, you can find the directory in C:\Program files (x86)\OpenBLAS\
.After you have installed all of the required dependencies, build the MXNet source code:
./build
..sln
, and compile it. These commands produce a library called mxnet.dll
in the ./build/Release/
or ./build/Debug
folder. Next, we install graphviz
library that we use for visualizing network graphs you build on MXNet. We will also install Jupyter Notebook used for running MXNet tutorials and examples.
graphviz
by downloading MSI installer from Graphviz Download Page. Note Make sure to add graphviz executable path to PATH environment variable. Refer here for more detailsJupyter
by installing Anaconda for Python 2.7 Note Do not install Anaconda for Python 3.5. MXNet has few compatibility issue with Python 3.5.
We have installed MXNet core library. Next, we will install MXNet interface package for programming language of your choice:
Python
using windows installer available here.Numpy
using windows installer available here.# Assuming you are in root mxnet source code folder cd python sudo python setup.py install
Done! We have installed MXNet with Python interface. Run below commands to verify our installation is successful.
# Open Python terminal python # You should be able to import mxnet library without any issues. >>> import mxnet as mx; >>> a = mx.nd.ones((2, 3)); >>> print ((a*2).asnumpy()); [[ 2. 2. 2.] [ 2. 2. 2.]]
We actually did a small tensor computation using MXNet! You are all set with MXNet on your Windows machine.
MXNet for R is available for both CPUs and GPUs.
To install MXNet on a computer with a CPU processor, choose from two options:
For Windows users, MXNet provides prebuilt binary packages. You can install the package directly in the R console.
For CPU-only package:
cran <- getOption("repos") cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/" options(repos = cran) install.packages("mxnet")
For GPU-enabled package:
cran <- getOption("repos") cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/GPU" options(repos = cran) install.packages("mxnet")
Run the following commands to install the MXNet dependencies and build the MXNet R package.
Rscript -e "install.packages('devtools', repo = 'https://cloud.r-project.org/')"
cd R-package Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cloud.r-project.org/')); install_deps(dependencies = TRUE)" cd .. make rpkg
Note: R-package is a folder in the MXNet source.
These commands create the MXNet R package as a tar.gz file that you can install as an R package. To install the R package, run the following command, use your MXNet version number:
R CMD INSTALL mxnet_current_r.tar.gz
To install MXNet R package on a computer with a GPU processor, you need the following:
Microsoft Visual Studio 2013
The NVidia CUDA Toolkit
The MXNet package
CuDNN (to provide a Deep Neural Network library)
To install the required dependencies and install MXNet for R:
git clone --recursive https://github.com/dmlc/mxnet
The --recursive
is to clone all the submodules used by MXNet. You will be editing the "/mxnet/R-package"
folder. 4. Download prebuilt GPU-enabled MXNet libraries for Windows from https://github.com/yajiedesign/mxnet/releases. You will need mxnet_x64_vc14_gpu.7z
and prebuildbase_win10_x64_vc14.7z
. 5. Download and install CuDNN. 6. Create a folder called R-package/inst/libs/x64
. MXNet supports only 64-bit operating systems, so you need the x64 folder. 7. Copy the following shared libraries (.dll files) into the R-package/inst/libs/x64
folder:
cublas64_80.dll cudart64_80.dll cudnn64_5.dll curand64_80.dll libgcc_s_seh-1.dll libgfortran-3.dll libmxnet.dll libmxnet.lib libopenblas.dll libquadmath-0.dll nvrtc64_80.dll
These dlls can be found in prebuildbase_win10_x64_vc14/3rdparty/cudart
, prebuildbase_win10_x64_vc14/3rdparty/openblas/bin
, mxnet_x64_vc14_gpu/build
, mxnet_x64_vc14_gpu/lib
and the cuDNN
downloaded from NVIDIA. 8. Copy the header files from dmlc
, mxnet
and nnvm
into ./R-package/inst/include
. It should look like:
./R-package/inst └── include ├── dmlc ├── mxnet └── nnvm
PATH
in the environment variables. Running the where R
command at the command prompt should return the location.mxnet
folder. Then use the following commands to build R package:echo import(Rcpp) > R-package\NAMESPACE echo import(methods) >> R-package\NAMESPACE Rscript -e "install.packages('devtools', repos = 'https://cloud.r-project.org')" cd R-package Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cloud.r-project.org')); install_deps(dependencies = TRUE)" cd .. R CMD INSTALL --no-multiarch R-package Rscript -e "require(mxnet); mxnet:::mxnet.export('R-package')" rm R-package/NAMESPACE Rscript -e "require(devtools); install_version('roxygen2', version = '5.0.1', repos = 'https://cloud.r-project.org/', quiet = TRUE)" Rscript -e "require(roxygen2); roxygen2::roxygenise('R-package')" R CMD INSTALL --build --no-multiarch R-package
Note: To maximize its portability, the MXNet library is built with the Rcpp end. Computers running Windows need MSVC (Microsoft Visual C++) to handle CUDA toolchain compatibilities.
The MXNet package for Julia is hosted in a separate repository, MXNet.jl, which is available on GitHub. To use Julia binding it with an existing libmxnet installation, set the MXNET_HOME
environment variable by running the following command:
export MXNET_HOME=/<path to>/libmxnet
The path to the existing libmxnet installation should be the root directory of libmxnet. In other words, you should be able to find the libmxnet.so
file at $MXNET_HOME/lib
. For example, if the root directory of libmxnet is ~
, you would run the following command:
export MXNET_HOME=/~/libmxnet
You might want to add this command to your ~/.bashrc
file. If you do, you can install the Julia package in the Julia console using the following command:
Pkg.add("MXNet")
For more details about installing and using MXNet with Julia, see the MXNet Julia documentation.
There are four ways to install the MXNet package for Scala:
Use the prebuilt binary package
Build the library from source code
For Linux and OS X (Mac) users, MXNet provides prebuilt binary packages that support computers with either GPU or CPU processors. To download and build these packages using Maven
, change the artifactId
in the following Maven dependency to match your architecture:
<dependency> <groupId>ml.dmlc.mxnet</groupId> <artifactId>mxnet-full_<system architecture></artifactId> <version>0.1.1</version> </dependency>
For example, to download and build the 64-bit CPU-only version for Linux, use:
<dependency> <groupId>ml.dmlc.mxnet</groupId> <artifactId>mxnet-full_2.10-linux-x86_64-cpu</artifactId> <version>0.1.1</version> </dependency>
If your native environment differs slightly from the assembly package, for example, if you use the openblas package instead of the atlas package, it's better to use the mxnet-core package and put the compiled Java native library in your load path:
<dependency> <groupId>ml.dmlc.mxnet</groupId> <artifactId>mxnet-core_2.10</artifactId> <version>0.1.1</version> </dependency>
Before you build MXNet for Scala from source code, you must complete Step 1. Build the Shared Library. After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Scala package:
make scalapkg
This command creates the JAR files for the assembly, core, and example modules. It also creates the native library in the native/{your-architecture}/target directory
, which you can use to cooperate with the core module.
To install the MXNet Scala package into your local Maven repository, run the following command from the MXNet source root directory:
make scalainstall