From d1e99039023891c080d0353ae1a10c17a44d4351 Mon Sep 17 00:00:00 2001 From: Qiang Kou Date: Thu, 25 May 2017 13:45:00 -0700 Subject: [PATCH] [R][DOC] update R installation guide --- docs/get_started/install.md | 249 ++++++++++++++++++++++++++++++++++-- 1 file changed, 240 insertions(+), 9 deletions(-) diff --git a/docs/get_started/install.md b/docs/get_started/install.md index 5d37da1e1d6c..bfa93aba3407 100644 --- a/docs/get_started/install.md +++ b/docs/get_started/install.md @@ -647,8 +647,200 @@ You could also run distributed deeplearning with *MXNet* on AWS using [Cloudform + + + +
+
+
+ +The CPU version of MXNet R package can be installed in R like other packages + +```r +install.packages("drat") +drat::addRepo("dmlc") +install.packages("mxnet") +``` + + +
+ + +
+ +Will be available soon. + +
+ +
+
+ + + +
+
+
+
+ +Building *MXNet* from source is a 2 step process. +1. Build the *MXNet* core shared library, `libmxnet.so`, from the C++ sources. +2. Build the language specific bindings. + +**Minimum Requirements** +1. [GCC 4.8](https://gcc.gnu.org/gcc-4.8/) or later to compile C++ 11. +2. [GNU Make](https://www.gnu.org/software/make/) + +
+ +**Build the MXNet core shared library** + +**Step 1** Install build tools and git. +```bash +$ sudo apt-get update +$ sudo apt-get install -y build-essential git +``` + +**Step 2** Install OpenBLAS. + +*MXNet* uses [BLAS](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) library for accelerated numerical computations on CPU machine. There are several flavors of BLAS libraries - [OpenBLAS](http://www.openblas.net/), [ATLAS](http://math-atlas.sourceforge.net/) and [MKL](https://software.intel.com/en-us/intel-mkl). In this step we install OpenBLAS. You can choose to install ATLAS or MKL. +```bash +$ sudo apt-get install -y libopenblas-dev +``` + +**Step 3** Install OpenCV. + +*MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations. +```bash +$ sudo apt-get install -y libopencv-dev +``` + +**Step 4** Download MXNet sources and build MXNet core shared library. + +```bash +$ git clone --recursive https://github.com/dmlc/mxnet +$ cd mxnet +$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas +``` + +*Note* - USE_OPENCV and USE_BLAS are make file flags to set compilation options to use OpenCV and BLAS library. You can explore and use more compilation options in `make/config.mk`. + +
+ +**Build and install the MXNet R binding** + + +```bash +$ make rpkg +$ R CMD INSTALL mxnet_current_r.tar.gz +``` + + +
+ +
+ +The following installation instructions have been tested on Ubuntu 14.04 and 16.04. + + +**Prerequisites** + +Install the following NVIDIA libraries to setup *MXNet* with GPU support: + +1. Install CUDA 8.0 following the NVIDIA's [installation guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/). +2. Install cuDNN 5 for CUDA 8.0 following the NVIDIA's [installation guide](https://developer.nvidia.com/cudnn). You may need to register with NVIDIA for downloading the cuDNN library. + +**Note:** Make sure to add CUDA install path to `LD_LIBRARY_PATH`. + +Example - *export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH* + +
+ +Building *MXNet* from source is a 2 step process. +1. Build the *MXNet* core shared library, `libmxnet.so`, from the C++ sources. +2. Build the language specific bindings. + +**Minimum Requirements** +1. [GCC 4.8](https://gcc.gnu.org/gcc-4.8/) or later to compile C++ 11. +2. [GNU Make](https://www.gnu.org/software/make/) + +
+ +**Build the MXNet core shared library** + +**Step 1** Install build tools and git. +```bash +$ sudo apt-get update +$ sudo apt-get install -y build-essential git +``` +**Step 2** Install OpenBLAS. + +*MXNet* uses [BLAS](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) library for accelerated numerical computations. There are several flavors of BLAS libraries - [OpenBLAS](http://www.openblas.net/), [ATLAS](http://math-atlas.sourceforge.net/) and [MKL](https://software.intel.com/en-us/intel-mkl). In this step we install OpenBLAS. You can choose to install ATLAS or MKL. +```bash +$ sudo apt-get install -y libopenblas-dev +``` + +**Step 3** Install OpenCV. + +*MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations. +```bash +$ sudo apt-get install -y libopencv-dev +``` + +**Step 4** Download MXNet sources and build MXNet core shared library. + +```bash +$ git clone --recursive https://github.com/dmlc/mxnet +$ cd mxnet +$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1 +``` + +*Note* - USE_OPENCV, USE_BLAS, USE_CUDA, USE_CUDA_PATH AND USE_CUDNN are make file flags to set compilation options to use OpenCV, OpenBLAS, CUDA and cuDNN libraries. You can explore and use more compilation options in `make/config.mk`. Make sure to set USE_CUDA_PATH to right CUDA installation path. In most cases it is - */usr/local/cuda*. + +
+ +**Build and install the MXNet R binding** + +```bash +$ make rpkg +$ R CMD INSTALL mxnet_current_r.tar.gz +``` + +
+ +
+
+ + + + +
+
+
+ +The CPU version of MXNet R package can be installed in R like other packages + + +```r +install.packages("drat") +drat::addRepo("dmlc") +install.packages("mxnet") +``` + + +
+ +
+ +Will be available soon. + +
+
+
+ + +
-
+
Follow the installation instructions [in this guide](./ubuntu_setup.md) to set up MXNet. @@ -658,7 +850,7 @@ Follow the installation instructions [in this guide](./ubuntu_setup.md) to set u
-
+
Follow the installation instructions [in this guide](./osx_setup.md) to set up MXNet. @@ -668,8 +860,8 @@ Follow the installation instructions [in this guide](./osx_setup.md) to set up M
-
-
+
+
Follow the installation instructions [in this guide](./windows_setup.md) to set up MXNet. @@ -1067,7 +1259,7 @@ Start the python terminal. ```bash $ python ``` - +
@@ -1091,7 +1283,7 @@ $
- +
@@ -1110,8 +1302,47 @@ array([[ 3., 3., 3.],
+ + +
+
+
+ +Run a short *MXNet* python program to create a 2X3 matrix of ones, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3. + +```r +library(mxnet) +a <- mx.nd.ones(c(2,3), ctx = mx.cpu()) +b <- a * 2 + 1 +b +``` + +
+
+
+ + + +
+
+
+ +Run a short *MXNet* python program to create a 2X3 matrix of ones *a* on a *GPU*, multiply each element in the matrix by 2 followed by adding 1. We expect the output to be a 2X3 matrix with all elements being 3. We use *mx.gpu()*, to set *MXNet* context to be GPUs. + +```r +library(mxnet) +a <- mx.nd.ones(c(2,3), ctx = mx.gpu()) +b <- a * 2 + 1 +b +``` + +
+
+
+ +
-
+
Will be available soon. @@ -1121,7 +1352,7 @@ Will be available soon.
-
+
Will be available soon. @@ -1131,7 +1362,7 @@ Will be available soon.
-
+
Will be available soon.