Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 8713d25

Browse files
thirdwingpiiswrong
authored andcommitted
[R][DOC] update R installation guide (#6457)
1 parent 65d3dcb commit 8713d25

File tree

1 file changed

+240
-9
lines changed

1 file changed

+240
-9
lines changed

docs/get_started/install.md

Lines changed: 240 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,200 @@ You could also run distributed deeplearning with *MXNet* on AWS using [Cloudform
648648

649649
<!-- END - Cloud Python Installation Instructions -->
650650

651+
652+
<!-- START - MacOS R CPU Installation Instructions -->
653+
654+
<div class="macos">
655+
<div class="r">
656+
<div class="cpu">
657+
658+
The CPU version of MXNet R package can be installed in R like other packages
659+
660+
```r
661+
install.packages("drat")
662+
drat::addRepo("dmlc")
663+
install.packages("mxnet")
664+
```
665+
666+
667+
</div>
668+
669+
670+
<div class="gpu">
671+
672+
Will be available soon.
673+
674+
</div>
675+
676+
</div>
677+
</div>
678+
<!-- END - MacOS R CPU Installation Instructions -->
679+
680+
681+
<div class="linux">
682+
<div class="r">
683+
<div class="cpu">
684+
<br/>
685+
686+
Building *MXNet* from source is a 2 step process.
687+
1. Build the *MXNet* core shared library, `libmxnet.so`, from the C++ sources.
688+
2. Build the language specific bindings.
689+
690+
**Minimum Requirements**
691+
1. [GCC 4.8](https://gcc.gnu.org/gcc-4.8/) or later to compile C++ 11.
692+
2. [GNU Make](https://www.gnu.org/software/make/)
693+
694+
<br/>
695+
696+
**Build the MXNet core shared library**
697+
698+
**Step 1** Install build tools and git.
699+
```bash
700+
$ sudo apt-get update
701+
$ sudo apt-get install -y build-essential git
702+
```
703+
704+
**Step 2** Install OpenBLAS.
705+
706+
*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.
707+
```bash
708+
$ sudo apt-get install -y libopenblas-dev
709+
```
710+
711+
**Step 3** Install OpenCV.
712+
713+
*MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations.
714+
```bash
715+
$ sudo apt-get install -y libopencv-dev
716+
```
717+
718+
**Step 4** Download MXNet sources and build MXNet core shared library.
719+
720+
```bash
721+
$ git clone --recursive https://github.com/dmlc/mxnet
722+
$ cd mxnet
723+
$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas
724+
```
725+
726+
*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`.
727+
728+
<br/>
729+
730+
**Build and install the MXNet R binding**
731+
732+
733+
```bash
734+
$ make rpkg
735+
$ R CMD INSTALL mxnet_current_r.tar.gz
736+
```
737+
738+
739+
</div>
740+
741+
<div class="gpu">
742+
743+
The following installation instructions have been tested on Ubuntu 14.04 and 16.04.
744+
745+
746+
**Prerequisites**
747+
748+
Install the following NVIDIA libraries to setup *MXNet* with GPU support:
749+
750+
1. Install CUDA 8.0 following the NVIDIA's [installation guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/).
751+
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.
752+
753+
**Note:** Make sure to add CUDA install path to `LD_LIBRARY_PATH`.
754+
755+
Example - *export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH*
756+
757+
<br/>
758+
759+
Building *MXNet* from source is a 2 step process.
760+
1. Build the *MXNet* core shared library, `libmxnet.so`, from the C++ sources.
761+
2. Build the language specific bindings.
762+
763+
**Minimum Requirements**
764+
1. [GCC 4.8](https://gcc.gnu.org/gcc-4.8/) or later to compile C++ 11.
765+
2. [GNU Make](https://www.gnu.org/software/make/)
766+
767+
<br/>
768+
769+
**Build the MXNet core shared library**
770+
771+
**Step 1** Install build tools and git.
772+
```bash
773+
$ sudo apt-get update
774+
$ sudo apt-get install -y build-essential git
775+
```
776+
**Step 2** Install OpenBLAS.
777+
778+
*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.
779+
```bash
780+
$ sudo apt-get install -y libopenblas-dev
781+
```
782+
783+
**Step 3** Install OpenCV.
784+
785+
*MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations.
786+
```bash
787+
$ sudo apt-get install -y libopencv-dev
788+
```
789+
790+
**Step 4** Download MXNet sources and build MXNet core shared library.
791+
792+
```bash
793+
$ git clone --recursive https://github.com/dmlc/mxnet
794+
$ cd mxnet
795+
$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1
796+
```
797+
798+
*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*.
799+
800+
<br/>
801+
802+
**Build and install the MXNet R binding**
803+
804+
```bash
805+
$ make rpkg
806+
$ R CMD INSTALL mxnet_current_r.tar.gz
807+
```
808+
809+
</div>
810+
811+
</div>
812+
</div>
813+
814+
815+
<!-- START - Windows R CPU Installation Instructions -->
816+
817+
<div class="windows">
818+
<div class="r">
819+
<div class="cpu">
820+
821+
The CPU version of MXNet R package can be installed in R like other packages
822+
823+
824+
```r
825+
install.packages("drat")
826+
drat::addRepo("dmlc")
827+
install.packages("mxnet")
828+
```
829+
830+
831+
</div>
832+
833+
<div class="gpu">
834+
835+
Will be available soon.
836+
837+
</div>
838+
</div>
839+
</div>
840+
841+
<!-- END - Windows R CPU Installation Instructions -->
842+
651843
<div class="linux">
652-
<div class="scala r julia perl">
844+
<div class="scala julia perl">
653845
<div class="cpu gpu">
654846

655847
Follow the installation instructions [in this guide](./ubuntu_setup.md) to set up MXNet.
@@ -659,7 +851,7 @@ Follow the installation instructions [in this guide](./ubuntu_setup.md) to set u
659851
</div>
660852

661853
<div class="macos">
662-
<div class="scala r julia perl">
854+
<div class="scala julia perl">
663855
<div class="cpu gpu">
664856

665857
Follow the installation instructions [in this guide](./osx_setup.md) to set up MXNet.
@@ -669,8 +861,8 @@ Follow the installation instructions [in this guide](./osx_setup.md) to set up M
669861
</div>
670862

671863
<div class="windows">
672-
<div class="python scala r julia perl">
673-
<div class="cpu gpu">
864+
<div class="python scala julia perl">
865+
<div class="gpu">
674866

675867
Follow the installation instructions [in this guide](./windows_setup.md) to set up MXNet.
676868

@@ -1068,7 +1260,7 @@ Start the python terminal.
10681260
```bash
10691261
$ python
10701262
```
1071-
<!-- Example code for CPU -->
1263+
<!-- Example Python code for CPU -->
10721264

10731265
<div class="cpu">
10741266

@@ -1092,7 +1284,7 @@ $
10921284

10931285
</div>
10941286

1095-
<!-- Example code for CPU -->
1287+
<!-- Example Python code for CPU -->
10961288

10971289
<div class="gpu">
10981290

@@ -1111,8 +1303,47 @@ array([[ 3., 3., 3.],
11111303

11121304
</div>
11131305

1306+
<!-- Example R code for CPU -->
1307+
1308+
<div class="linux macos windows">
1309+
<div class="r">
1310+
<div class="cpu">
1311+
1312+
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.
1313+
1314+
```r
1315+
library(mxnet)
1316+
a <- mx.nd.ones(c(2,3), ctx = mx.cpu())
1317+
b <- a * 2 + 1
1318+
b
1319+
```
1320+
1321+
</div>
1322+
</div>
1323+
</div>
1324+
1325+
<!-- Example R code for GPU -->
1326+
1327+
<div class="linux macos windows">
1328+
<div class="r">
1329+
<div class="gpu">
1330+
1331+
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.
1332+
1333+
```r
1334+
library(mxnet)
1335+
a <- mx.nd.ones(c(2,3), ctx = mx.gpu())
1336+
b <- a * 2 + 1
1337+
b
1338+
```
1339+
1340+
</div>
1341+
</div>
1342+
</div>
1343+
1344+
11141345
<div class="linux">
1115-
<div class="scala r julia perl">
1346+
<div class="scala julia perl">
11161347
<div class="cpu gpu">
11171348

11181349
Will be available soon.
@@ -1122,7 +1353,7 @@ Will be available soon.
11221353
</div>
11231354

11241355
<div class="macos">
1125-
<div class="scala r julia perl">
1356+
<div class="scala julia perl">
11261357
<div class="cpu gpu">
11271358

11281359
Will be available soon.
@@ -1132,7 +1363,7 @@ Will be available soon.
11321363
</div>
11331364

11341365
<div class="windows">
1135-
<div class="python scala r julia perl">
1366+
<div class="python scala julia perl">
11361367
<div class="cpu gpu">
11371368

11381369
Will be available soon.

0 commit comments

Comments
 (0)