Installing MXNet in Windows¶
On Windows, you can download and install the prebuilt MXNet package, or download, build, and install MXNet yourself.
Install MXNet for Python¶
Pythonusing windows installer available here.
Numpyusing windows installer available here.
- Next, we install Python package interface for MXNet. You can find the Python interface package for MXNet on GitHub.
# 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.
Install MXNet for R¶
MXNet for R is available for both CPUs and GPUs.
Installing MXNet on a Computer with a CPU Processor¶
To install MXNet on a computer with a CPU processor, choose from two options:
- Use the prebuilt binary package
- Build the library from source code
Installing MXNet with the Prebuilt Binary Package¶
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://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" options(repos = cran) install.packages("mxnet")
For GPU-enabled package:
cran <- getOption("repos") cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/GPU" options(repos = cran) install.packages("mxnet")
Building MXNet from Source Code¶
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
Installing MXNet on a Computer with a GPU Processor¶
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:
- Install the CUDA Toolkit. The CUDA Toolkit depends on Visual Studio. To check whether your GPU is compatible with the CUDA Toolkit and for information on installing it, see NVidia’s CUDA Installation Guide.
- Clone the MXNet github repo.
git clone --recursive https://github.com/dmlc/mxnet
--recursive is to clone all the submodules used by MXNet. You will be editing the
- Download prebuilt GPU-enabled MXNet libraries for Windows from https://github.com/yajiedesign/mxnet/releases. You will need
- Download and install CuDNN.
- Create a folder called
R-package/inst/libs/x64. MXNet supports only 64-bit operating systems, so you need the x64 folder.
- Copy the following shared libraries (.dll files) into the
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
mxnet_x64_vc14_gpu/lib and the
cuDNN downloaded from NVIDIA.
- Copy the header files from
./R-package/inst/include. It should look like:
./R-package/inst └── include ├── dmlc ├── mxnet └── nnvm
- Make sure that R is added to your
PATHin the environment variables. Running the
where Rcommand at the command prompt should return the location.
- Now open the Windows CMD and change the directory to the
mxnetfolder. 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.
Install the MXNet Package for Julia¶
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:
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:
For more details about installing and using MXNet with Julia, see the MXNet Julia documentation.
Installing the MXNet Package for Scala¶
Scala-MXNet is not yet available for Windows.