From d7111d357dd682e9e75c6adc5c73e6b74c5541dd Mon Sep 17 00:00:00 2001 From: Aaron Markham Date: Wed, 5 Sep 2018 14:31:42 -0700 Subject: [PATCH] Installation instructions consolidation (#12388) * initial edits for c++ instructions * consolidation and reorg of install docs * simplify python section * fix url rewrite to allow for testing * further simplify install * fix render issues * adjust formatting * adjust formatting * fix python/gpu/master * install footers * update footers * add mac dev setup link for osx * adjust formatting for footer * separate validation page * add toc * adjust formatting * break out julia and perl * fix pypi link * fix formatting * fix formatting * fix formatting * add build from source link * updating from PR feedback * add c++ and clojure to ubuntu guide; clarify c++ setup * added pip chart to install; updates from PR feedback * correct reference to c infer api --- docs/_static/js/options.js | 20 +- docs/install/build_from_source.md | 493 ++---- docs/install/c_plus_plus.md | 29 + docs/install/centos_setup.md | 98 +- docs/install/index.md | 2523 ++++++----------------------- docs/install/osx_setup.md | 11 + docs/install/ubuntu_setup.md | 181 ++- docs/install/validate_mxnet.md | 185 +++ docs/install/windows_setup.md | 14 +- 9 files changed, 1093 insertions(+), 2461 deletions(-) create mode 100644 docs/install/c_plus_plus.md create mode 100644 docs/install/validate_mxnet.md diff --git a/docs/_static/js/options.js b/docs/_static/js/options.js index 87e50b8aa865..b43f3919a313 100644 --- a/docs/_static/js/options.js +++ b/docs/_static/js/options.js @@ -8,7 +8,7 @@ $(document).ready(function () { function label(lbl) { return lbl.replace(/[ .]/g, '-').toLowerCase(); } - + function urlSearchParams(searchString) { let urlDict = new Map(); let searchParams = searchString.substring(1).split("&"); @@ -45,11 +45,11 @@ $(document).ready(function () { showContent(); if (window.location.href.indexOf("/install/index.html") >= 0) { if (versionSelect.indexOf(defaultVersion) >= 0) { - history.pushState(null, null, '/install/index.html?platform=' + platformSelect + '&language=' + languageSelect + '&processor=' + processorSelect); + history.pushState(null, null, 'index.html?platform=' + platformSelect + '&language=' + languageSelect + '&processor=' + processorSelect); } else { - history.pushState(null, null, '/install/index.html?version=' + versionSelect + '&platform=' + platformSelect + '&language=' + languageSelect + '&processor=' + processorSelect); + history.pushState(null, null, 'index.html?version=' + versionSelect + '&platform=' + platformSelect + '&language=' + languageSelect + '&processor=' + processorSelect); } - } + } } function showContent() { @@ -73,22 +73,22 @@ $(document).ready(function () { $('.current-version').html( $(this).text() + ' ' ); if ($(this).text().indexOf(defaultVersion) < 0) { if (window.location.search.indexOf("version") < 0) { - history.pushState(null, null, '/install/index.html' + window.location.search.concat( '&version=' + $(this).text() )); + history.pushState(null, null, 'index.html' + window.location.search.concat( '&version=' + $(this).text() )); } else { - history.pushState(null, null, '/install/index.html' + window.location.search.replace( urlParams.get('version'), $(this).text() )); + history.pushState(null, null, 'index.html' + window.location.search.replace( urlParams.get('version'), $(this).text() )); } } else if (window.location.search.indexOf("version") >= 0) { - history.pushState(null, null, '/install/index.html' + window.location.search.replace( 'version', 'prev' )); + history.pushState(null, null, 'index.html' + window.location.search.replace( 'version', 'prev' )); } } else if ($(this).hasClass("platforms")) { - history.pushState(null, null, '/install/index.html' + window.location.search.replace( urlParams.get('platform'), $(this).text() )); + history.pushState(null, null, 'index.html' + window.location.search.replace( urlParams.get('platform'), $(this).text() )); } else if ($(this).hasClass("languages")) { - history.pushState(null, null, '/install/index.html' + window.location.search.replace( urlParams.get('language'), $(this).text() )); + history.pushState(null, null, 'index.html' + window.location.search.replace( urlParams.get('language'), $(this).text() )); } else if ($(this).hasClass("processors")) { - history.pushState(null, null, '/install/index.html' + window.location.search.replace( urlParams.get('processor'), $(this).text() )); + history.pushState(null, null, 'index.html' + window.location.search.replace( urlParams.get('processor'), $(this).text() )); } showContent(); //window.location.search = window.location.search.replace( urlParams.get('version'), $(this).text() ); diff --git a/docs/install/build_from_source.md b/docs/install/build_from_source.md index b22ff8833e9d..6c0a4dab251a 100644 --- a/docs/install/build_from_source.md +++ b/docs/install/build_from_source.md @@ -1,22 +1,23 @@ # Build MXNet from Source -**NOTE:** For MXNet with Python installation, please refer to the [new install guide](http://mxnet.io/install/index.html). - -This document explains how to build MXNet from sources. Building MXNet from sources is a 2 step process. +This document explains how to build MXNet from source code. Building MXNet from source is a two step process. 1. Build the MXNet shared library, `libmxnet.so`, from [C++ source files](#build-the-shared-library) -2. Install the language binding for MXNet. MXNet supports - - [C++](#build-the-c-package), - [Scala](#build-the-scala-package), [R](#build-the-r-package), and - [Julia](#build-the-julia-package). +2. Install the [language bindings](#installing-mxnet-language-bindings) for MXNet. MXNet supports the following languages: + - Python + - C++ + - Clojure + - Julia + - Perl + - R + - Scala -## Build the shared library +## Prerequisites -### Prerequisites +You need C++ build tools and a BLAS library to build the MXNet shared library. If you want to run MXNet with GPUs, you will need to install [NVDIA CUDA and cuDNN](https://developer.nvidia.com/cuda-downloads) first. -You need C++ build tools and BLAS library to build MXNet shared library. If you want to run MXNet on GPUs, you need to install CUDA and CuDNN. -#### C++ build tools +### C++ build tools 1. A C++ compiler that supports C++ 11. [G++ (4.8 or later)](https://gcc.gnu.org/gcc-4.8/) or @@ -24,311 +25,138 @@ You need C++ build tools and BLAS library to build MXNet shared library. If you 2. [Git](https://git-scm.com/downloads) for downloading the sources from Github repository. -3. [GNU Make](https://www.gnu.org/software/make/) ([cmake](https://cmake.org/) - for Windows) to build the library. - - -Select your preferences and follow the instructions to install MXNet from sources. -
- - - -
- - -
- -Then select the Linux distribution: -
- - - -
- -- **Ubuntu** for systems supporting the `apt-get` - package management program -- **CentOS** for systems supporting the `yum` package - management program -- **Others** for general Linux-like systems building dependencies from scratch. - -
- -Install build tools and git on `Ubuntu >= 13.10` and `Debian >= 8`. - -```bash -sudo apt-get update && sudo apt-get install build-essential git -``` - -
- -
- -Install build tools and git on `CentOS >= 7` and `Fedora >= 19`. - -```bash -sudo yum groupinstall -y "Development Tools" && sudo yum install -y git -``` - -
- -
- -Installing both `git` and `make` by following instructions on the websites is -straightforward. Here we provide the instructions to build `gcc-4.8` from source codes. - -1. Install the 32-bit `libc` with one of the following system-specific commands: - - ```bash - sudo apt-get install libc6-dev-i386 # In Ubuntu - sudo yum install glibc-devel.i686 # In RHEL (Red Hat Linux) - sudo yum install glibc-devel.i386 # In CentOS 5.8 - sudo yum install glibc-devel.i686 # In CentOS 6/7 - ``` - -2. Download and extract the `gcc` source code with the prerequisites: - - ```bash - wget http://mirrors.concertpass.com/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz - tar -zxf gcc-4.8.5.tar.gz - cd gcc-4.8.5 - ./contrib/download_prerequisites - ``` - -3. Build `gcc` by using 10 threads and then install to `/usr/local` - - ```bash - mkdir release && cd release - ../configure --prefix=/usr/local --enable-languages=c,c++ - make -j10 - sudo make install - ``` - -4. Add the lib path to your configure file such as `~/.bashrc`: - - ```bash - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64 - ``` +3. [cmake](https://cmake.org/) is recommended. You may also use [GNU Make](https://www.gnu.org/software/make/) to build the library. -
-
-
- -1. If [Microsoft Visual Studio 2015](https://www.visualstudio.com/downloads/) is not already installed, download and install it. You can download and install the free community edition. -2. Download and Install [CMake](https://cmake.org/) if it is not already installed. - -
- -
- -Install [Xcode](https://developer.apple.com/xcode/). - -
- -#### BLAS library +### BLAS library MXNet relies on the [BLAS](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) (Basic -Linear Algebra Subprograms) library for numerical computations. You can install -any one among [ATLAS](http://math-atlas.sourceforge.net/), -[OpenBLAS](http://www.openblas.net/) and -[MKL](https://software.intel.com/en-us/intel-mkl). - -
-
+Linear Algebra Subprograms) library for numerical computations. +Those can be extended with [LAPACK (Linear Algebra Package)](https://github.com/Reference-LAPACK/lapack), an additional set of mathematical functions. -```bash -sudo apt-get install libatlas-base-dev -``` +MXNet supports multiple mathematical backends for computations on the CPU: -
+* [Apple Accelerate](https://developer.apple.com/documentation/accelerate) +* [ATLAS](http://math-atlas.sourceforge.net/) +* [MKL](https://software.intel.com/en-us/intel-mkl) (MKL, MKLML) +* [MKLDNN](https://github.com/intel/mkl-dnn) +* [OpenBLAS](http://www.openblas.net/) -
+Usage of these are covered in more detail in the [build configurations](#build-configurations) section. -```bash -sudo yum install atlas-devel -``` -
+### Optional -
+These might be optional, but they're typically desirable. -You can follow this link to build -[OpenBlas from source](https://github.com/xianyi/OpenBLAS#installation-from-source). +* [OpenCV](http://opencv.org/) for Image Loading and Augmentation +* [NVDIA CUDA and cuDNN](https://developer.nvidia.com/cuda-downloads) for running MXNet with GPUs -
-
-
+## Build Instructions by Operating System -macOS users can skip this step as `xcode` ships with a BLAS library. +Detailed instructions are provided per operating system. +You may jump to those, but it is recommended that you continue reading to understand more general build from source options. -
+| | | | | +|---|---|---|---| +| [macOS](osx_setup.html) | [Ubuntu](ubuntu_setup.html) | [CentOS/*unix](centos_setup.html) | [Windows](windows_setup.html) | +| [raspbian](raspian_setup.html) | [tx2](tx2_setup.html) | | | -
-1. Download pre-built binaries for [OpenBLAS](https://sourceforge.net/projects/openblas/files/) -2. Set the environment variable `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\`. -
- -#### Optional: [OpenCV](http://opencv.org/) for Image Loading and Augmentation - -
-
+## Build +1. Clone the MXNet project. ```bash -sudo apt-get install libopencv-dev -``` - -
- -
- -```bash -sudo apt-get install opencv-devel +git clone --recursive https://github.com/apache/incubator-mxnet mxnet +cd mxnet ``` -
- -
- -To build OpenCV from source code, you need the [cmake](https://cmake.org) library. - -1. If you don't have cmake or if your version of cmake is earlier than 3.6.1, run the following commands to install a newer version of cmake: - - ```bash - wget https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz - tar -zxvf cmake-3.6.1-Linux-x86_64.tar.gz - alias cmake="cmake-3.6.1-Linux-x86_64/bin/cmake" - ``` - -2. To download and extract the OpenCV source code, run the following commands: - - ```bash - wget https://codeload.github.com/opencv/opencv/zip/2.4.13 - unzip 2.4.13 - cd opencv-2.4.13 - mkdir release - cd release/ - ``` - -3. Build OpenCV. The following commands build OpenCV with 10 threads. We - disabled GPU support, which might significantly slow down an MXNet program - running on a GPU processor. It also disables 1394 which might generate a - warning. Then install it on `/usr/local`. - - ```bash - cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. - make -j10 - sudo make install - ``` +There is a configuration file for make, +[`make/config.mk`](https://github.com/apache/incubator-mxnet/blob/master/make/config.mk), that contains all the compilation options. You can edit it and then run `make`. -4. Add the lib path to your configuration such as `~/.bashrc`. - ```bash - export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/ - ``` +## Build Configurations -
-
+`cmake` is recommended for building MXNet, however you may use `make` instead. -
-First download and install [OpenCV](http://opencv.org/releases.html), then set -the environment variable `OpenCV_DIR` to point to the OpenCV build directory. +### Math Library Selection +It is useful to consider your math library selection first. -
+The default order of choice for the libraries if found follows the path from the most +(recommended) to less performant backends. +The following lists show this order by library and `cmake` switch. -#### Optional: [CUDA](https://developer.nvidia.com/cuda-downloads)/[cuDNN](https://developer.nvidia.com/cudnn) for Nvidia GPUs +For desktop platforms (x86_64): -MXNet is compatible with both CUDA 7.5 and 8.0. It is recommended to use cuDNN 5. +1. MKLDNN (submodule) | `USE_MKLDNN` +2. MKL | `USE_MKL_IF_AVAILABLE` +3. MKLML (downloaded) | `USE_MKLML` +4. Apple Accelerate | `USE_APPLE_ACCELERATE_IF_AVAILABLE` | Mac only +5. OpenBLAS | `BLAS` | Options: Atlas, Open, MKL, Apple -
-
+Note: If `USE_MKL_IF_AVAILABLE` is set to False then MKLML and MKLDNN will be disabled as well for configuration +backwards compatibility. -Install CUDA 7.5 and cuDNN 5 on Ubuntu 14.04 +For embedded platforms (all other and if cross compiled): -```bash -wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb -sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb -echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64 /" | sudo tee /etc/apt/sources.list.d/nvidia-ml.list -sudo apt-get update -sudo apt-get install -y linux-image-extra-`uname -r` linux-headers-`uname -r` linux-image-`uname -r` -sudo apt-get install -y cuda libcudnn5-dev=5.0.5-1+cuda7.5 -``` - -
-
- -### Build - -
- -First clone the recent codes - -```bash -git clone --recursive https://github.com/dmlc/mxnet -cd mxnet -``` - -File -[`make/config.mk`](https://github.com/dmlc/mxnet/blob/master/make/config.mk) -contains all the compilation options. You can edit it and then `make`. There are -some example build options - -If you want to build MXNet with C++ language binding, please make sure you read [Build the C++ package](#build-the-c-package) first. - -
- -
+1. OpenBLAS | `BLAS` | Options: Atlas, Open, MKL, Apple -- Build without using OpenCV. `-j` runs multiple jobs against multi-core CPUs. +You can set the BLAS library explicitly by setting the BLAS variable to: - ```bash - make -j USE_OPENCV=0 - ``` +* Atlas +* Open +* MKL +* Apple -- Build with both GPU and OpenCV support +See the [cmake/ChooseBLAS.cmake](https://github.com/apache/incubator-mxnet/blob/master/cmake/ChooseBlas.cmake) file for the options. - ```bash - make -j USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1 - ``` +Intel's MKL (Math Kernel Library) is one of the most powerful math libraries +https://software.intel.com/en-us/mkl -
+It has following flavors: -
+* MKL is a complete math library, containing all the functionality found in ATLAS, OpenBlas and LAPACK. It is free under + community support licensing (https://software.intel.com/en-us/articles/free-mkl), + but needs to be downloaded and installed manually. -- Build with the default BLAS library and clang installed with `xcode` (OPENMP - is disabled because it is not supported in default by clang). +* MKLML is a subset of MKL. It contains a smaller number of functions to reduce the + size of the download and reduce the number of dynamic libraries user needs. - ```bash - make -j USE_BLAS=apple USE_OPENCV=0 USE_OPENMP=0 - ``` + -
+* MKLDNN is a separate open-source library, it can be used separately from MKL or MKLML. It is + shipped as a subrepo with MXNet source code (see 3rdparty/mkldnn or the [mkl-dnn project](https://github.com/intel/mkl-dnn)) -
+Since the full MKL library is almost always faster than any other BLAS library it's turned on by default, +however it needs to be downloaded and installed manually before doing `cmake` configuration. +Register and download on the [Intel performance libraries website](https://software.seek.intel.com/performance-libraries). -Use [CMake](https://cmake.org/) to create a Visual Studio solution in ```./build```. +Note: MKL is supported only for desktop builds and the framework itself supports the following +hardware: -In Visual Studio, open the solution file,```.sln```, and compile it. -These commands produce a library called ```mxnet.dll``` in the ```./build/Release/``` or ```./build/Debug``` folder. +* Intel® Xeon Phi™ processor +* Intel® Xeon® processor +* Intel® Core™ processor family +* Intel Atom® processor -
+If you have a different processor you can still try to use MKL, but performance results are +unpredictable. -
-## Build MXNet using NCCL +### Build MXNet with NCCL - Download and install the latest NCCL library from NVIDIA. - Note the directory path in which NCCL libraries and header files are installed. - Ensure that the installation directory contains ```lib``` and ```include``` folders. -- Ensure that the prerequisites for using NCCL such as Cuda libraries are met. +- Ensure that the prerequisites for using NCCL such as Cuda libraries are met. - Append the ```config.mk``` file with following, in addition to the CUDA related options. - USE_NCCL=1 - USE_NCCL_PATH=path-to-nccl-installation-folder + ``` bash echo "USE_NCCL=1" >> make/config.mk echo "USE_NCCP_PATH=path-to-nccl-installation-folder" >> make/config.mk @@ -339,7 +167,7 @@ cp make/config.mk . make -j"$(nproc)" ``` -## Validation +#### Validating NCCL - Follow the steps to install MXNet Python binding. - Comment the following line in ```test_nccl.py``` file at ```incubator-mxnet/tests/python/gpu/test_nccl.py``` ``` bash @@ -350,143 +178,56 @@ make -j"$(nproc)" nosetests --verbose tests/python/gpu/test_nccl.py ``` -## Recommendation for best performance +**Recommendation to get the best performance out of NCCL:** It is recommended to set environment variable NCCL_LAUNCH_MODE to PARALLEL when using NCCL version 2.1 or newer. -
- -## Build the C++ package -The C++ package has the same prerequisites as the MXNet library, you should also have `python` installed. (Both `python` 2 and 3 are supported) - -To enable C++ package, just add `USE_CPP_PACKAGE=1` in the build options when building the MXNet shared library. - -## Build the R package +### Build MXNet with Language Packages +* To enable C++ package, just add `USE_CPP_PACKAGE=1` when you run `make` or `cmake`. -The R package requires `R` to be installed. -
- -Follow the below instructions to install the latest R on Ubuntu 14.04 (trusty) and also the libraries used -to build other R package dependencies. +### Usage Examples +* `-j` runs multiple jobs against multi-core CPUs. Example using all cores on Linux: ```bash -echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list -gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 -gpg -a --export E084DAB9 | apt-key add - - -apt-get update -apt-get install -y r-base r-base-dev libxml2-dev libxt-dev libssl-dev +make -j$(nproc) ``` -
- -Install the required R package dependencies: +* Build without using OpenCV: ```bash -cd R-package -Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')" -Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cran.rstudio.com')); install_deps(dependencies = TRUE)" +make USE_OPENCV=0 ``` -Next, build and install the MXNet R package: +* Build with both OpenBLAS, GPU, and OpenCV support: ```bash -cd .. -make rpkg +make -j USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1 ``` -## Build the Scala package - -Both JDK and Maven are required to build the Scala package. - -
+* Build on **macOS** with the default BLAS library (Apple Accelerate) and Clang installed with `xcode` (OPENMP is disabled because it is not supported by the Apple version of Clang): ```bash -apt-get install -y software-properties-common -add-apt-repository -y ppa:webupd8team/java -apt-get update -echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections -apt-get install -y oracle-java8-installer -apt-get install -y oracle-java8-set-default -apt-get install -y maven +make -j USE_BLAS=apple USE_OPENCV=0 USE_OPENMP=0 ``` -
- -The following command builds the `.jar` package: +* To use OpenMP on **macOS** you need to install the Clang compiler, `llvm` (the one provided by Apple does not support OpenMP): ```bash -make scalapkg +brew install llvm +make -j USE_BLAS=apple USE_OPENMP=1 ``` -which can be found by `ls scala-package/assembly/*/target/*SNAPSHOT.jar`. - -Optionally, we can install Scala for the interactive interface. +## Installing MXNet Language Bindings +After building MXNet's shared library, you can install other language bindings. (Except for C++. You need to build this when you build MXNet from source.) -
- -```bash -wget http://downloads.lightbend.com/scala/2.11.8/scala-2.11.8.deb -dpkg -i scala-2.11.8.deb -rm scala-2.11.8.deb -``` - -
- -Then we can start `scala` with `mxnet` imported by - -```bash -scala -cp scala-package/assembly/*/target/*SNAPSHOT.jar -``` - -## Build the Julia package - -We need to first install Julia. - -
- -The following commands install Julia 0.5.1 - -```bash -wget -q https://julialang.s3.amazonaws.com/bin/linux/x64/0.5/julia-0.5.1-linux-x86_64.tar.gz -tar -zxf julia-0.5.1-linux-x86_64.tar.gz -rm julia-0.5.1-linux-x86_64.tar.gz -ln -s $(pwd)/julia-6445c82d00/bin/julia /usr/bin/julia -``` - -
- -Next set the environment variable `MXNET_HOME=/path/to/mxnet` so that Julia -can find the pre-built library. - -Install the Julia package for MXNet with: - -```bash -julia -e 'Pkg.add("MXNet")' -``` - -### Build the Perl package - -Run the following command from the MXNet source root directory to build the MXNet Perl package: - -```bash - sudo apt-get install libmouse-perl pdl cpanminus swig libgraphviz-perl - cpanm -q -L "${HOME}/perl5" Function::Parameters Hash::Ordered PDL::CCS - - MXNET_HOME=${PWD} - export LD_LIBRARY_PATH=${MXNET_HOME}/lib - export PERL5LIB=${HOME}/perl5/lib/perl5 - - cd ${MXNET_HOME}/perl-package/AI-MXNetCAPI/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install - - cd ${MXNET_HOME}/perl-package/AI-NNVMCAPI/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install - - cd ${MXNET_HOME}/perl-package/AI-MXNet/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install -``` +The following table provides links to each language binding by operating system: +| | Linux | macOS | Windows | +|---|---|---|---| +| Python | [Linux](ubuntu_setup.html#install-mxnet-for-python) | [macOS](osx_setup.html) | [Windows](windows_setup.html#install-mxnet-for-python) | +| C++ | [Linux](c_plus_plus.html) | [macOS](c_plus_plus.html) | [Windows](c_plus_plus.html) | +| Clojure | [Linux](https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package) | [macOS](https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package) | n/a | +| Julia | [Linux](ubuntu_setup.html#install-the-mxnet-package-for-julia) | [macOS](osx_setup.html#install-the-mxnet-package-for-julia) | [Windows](windows_setup.html#install-the-mxnet-package-for-julia) | +| Perl | [Linux](ubuntu_setup.html#install-the-mxnet-package-for-perl) | [macOS](osx_setup.html#install-the-mxnet-package-for-perl) | [Windows](n/a) | +| R | [Linux](ubuntu_setup.html#install-the-mxnet-package-for-r) | [macOS](osx_setup.html#install-the-mxnet-package-for-r) | [Windows](windows_setup.html#install-the-mxnet-package-for-r) | +| Scala | [Linux](scala_setup.html) | [macOS](scala_setup.html) | n/a | diff --git a/docs/install/c_plus_plus.md b/docs/install/c_plus_plus.md new file mode 100644 index 000000000000..6078877c27c8 --- /dev/null +++ b/docs/install/c_plus_plus.md @@ -0,0 +1,29 @@ +## Build the C++ package +The C++ package has the same prerequisites as the MXNet library. + +To enable C++ package, just add `USE_CPP_PACKAGE=1` in the [build from source](build_from_source.html) options when building the MXNet shared library. + +For example to build MXNet with GPU support and the C++ package, OpenCV, and OpenBLAS, from the project root you would run: + +```bash +make -j USE_CPP_PACKAGE=1 USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 +``` + +You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH`: + +```bash +export LD_LIBRARY_PATH=~/incubator-mxnet/lib +``` + +Setting the `LD_LIBRARY_PATH` is required to run the examples mentioned in the following section. + +## C++ Example Code +You can find C++ code examples in the `cpp-package/example` folder of the MXNet project. Refer to the [cpp-package's README](https://github.com/apache/incubator-mxnet/tree/master/cpp-package) for instructions on building the examples. + +## Tutorials + +* [MXNet C++ API Basics](https://mxnet.incubator.apache.org/tutorials/c++/basics.html) + +## Related Topics + +* [Image Classification using MXNet's C Predict API](https://github.com/apache/incubator-mxnet/tree/master/example/image-classification/predict-cpp) diff --git a/docs/install/centos_setup.md b/docs/install/centos_setup.md index 42a4fcb0eb89..f63099bcf623 100644 --- a/docs/install/centos_setup.md +++ b/docs/install/centos_setup.md @@ -1,8 +1,90 @@ - - - -

- - This content is moved to a new MXNet install page. Redirecting... -

+# Installing MXNet on CentOS and other non-Ubuntu Linux systems + +1. Install build tools and git on `CentOS >= 7` and `Fedora >= 19`: + +```bash +sudo yum groupinstall -y "Development Tools" && sudo yum install -y git +``` + +2. Install Atlas: + +```bash +sudo yum install atlas-devel +``` + +Installing both `git` and `cmake` or `make` by following instructions on the websites is +straightforward. Here we provide the instructions to build `gcc-4.8` from source codes. + +3. Install the 32-bit `libc` with one of the following system-specific commands: + +```bash +sudo apt-get install libc6-dev-i386 # In Ubuntu +sudo yum install glibc-devel.i686 # In RHEL (Red Hat Linux) +sudo yum install glibc-devel.i386 # In CentOS 5.8 +sudo yum install glibc-devel.i686 # In CentOS 6/7 +``` + +4. Download and extract the `gcc` source code with the prerequisites: + +```bash +wget http://mirrors.concertpass.com/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.gz +tar -zxf gcc-4.8.5.tar.gz +cd gcc-4.8.5 +./contrib/download_prerequisites +``` + +5. Build `gcc` by using 10 threads and then install to `/usr/local` + +```bash +mkdir release && cd release +../configure --prefix=/usr/local --enable-languages=c,c++ +make -j10 +sudo make install +``` + +6. Add the lib path to your configure file such as `~/.bashrc`: + +```bash +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib64 +``` + +7. Build [OpenBLAS from source](https://github.com/xianyi/OpenBLAS#installation-from-source). + +8. Build OpenCV + +To build OpenCV from source code, you need the [cmake](https://cmake.org) library. + +* If you don't have cmake or if your version of cmake is earlier than 3.6.1, run the following commands to install a newer version of cmake: + + ```bash + wget https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz + tar -zxvf cmake-3.6.1-Linux-x86_64.tar.gz + alias cmake="cmake-3.6.1-Linux-x86_64/bin/cmake" + ``` + +* To download and extract the OpenCV source code, run the following commands: + + ```bash + wget https://codeload.github.com/opencv/opencv/zip/2.4.13 + unzip 2.4.13 + cd opencv-2.4.13 + mkdir release + cd release/ + ``` + +* Build OpenCV. The following commands build OpenCV with 10 threads. We + disabled GPU support, which might significantly slow down an MXNet program + running on a GPU processor. It also disables 1394 which might generate a + warning. Then install it on `/usr/local`. + + ```bash + cmake -D BUILD_opencv_gpu=OFF -D WITH_CUDA=OFF -D WITH_1394=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. + make -j10 + sudo make install + ``` + +* Add the lib path to your configuration such as `~/.bashrc`. + + ```bash + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/ + ``` diff --git a/docs/install/index.md b/docs/install/index.md index 833bedf08afa..4a6af31cee3c 100644 --- a/docs/install/index.md +++ b/docs/install/index.md @@ -1,6 +1,6 @@ # Installing MXNet -Indicate your preferred configuration. Then, follow the customized commands to install *MXNet*. +Indicate your preferred configuration. Then, follow the customized commands to install MXNet. - +
@@ -78,88 +77,27 @@ Indicate your preferred configuration. Then, follow the customized commands to i
- -The following installation instructions have been tested on Ubuntu 14.04 and 16.04. - -
-
- -**Step 1** Install prerequisites - wget and latest pip. - -Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command in the terminal. - -```bash -$ sudo apt-get update -$ sudo apt-get install -y wget python gcc -$ wget https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py -``` -
-**Step 2** Install MXNet with OpenBLAS acceleration. - -```bash -$ pip install mxnet -``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz ``` - -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl +$ pip install mxnet ```
-**Step 2** Install MXNet with OpenBLAS acceleration. - -```bash -$ pip install mxnet==1.1.0 -``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz ``` - -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl==1.1.0 +$ pip install mxnet==1.1.0 ```
-**Step 2** Install MXNet with OpenBLAS acceleration. - -```bash -$ pip install mxnet==1.0.0 -``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz ``` - -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl==1.0.0 +$ pip install mxnet==1.0.0 ```
@@ -167,210 +105,159 @@ $ pip install mxnet-mkl==1.0.0
- -**Step 2** Install MXNet with OpenBLAS acceleration. - -```bash -$ pip install mxnet==0.12.1 -``` - -For MXNet 0.12.0 - - -```bash -$ pip install mxnet==0.12.0 ``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz +$ pip install mxnet==0.12.1 ``` -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +For MXNet 0.12.0: -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl==0.12.1 ``` - -For MXNet 0.12.0 - - -```bash -$ pip install mxnet-mkl==0.12.0 +$ pip install mxnet==0.12.0 ```
- -**Step 2** Install MXNet with OpenBLAS acceleration. - -```bash +``` $ pip install mxnet==0.11.0 ``` -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` +
-**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +
-**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl==0.11.0 +``` +$ pip install mxnet --pre ``` -
+
+
+Most MXNet versions offer an experimental MKL pip package that will be much faster when running on Intel hardware. +Check the chart below for other options, refer to PyPI for other MXNet pip packages, or validate your MXNet installation. -
+pip packages +
-**Step 2** Install MXNet with OpenBLAS acceleration. -```bash -$ pip install mxnet --pre -``` +
+
-**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` +Docker images with *MXNet* are available at [Docker Hub](https://hub.docker.com/r/mxnet/). -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository). -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-mkl --pre -``` +*Note* - You can install Community Edition (CE) to get started with *MXNet*. -
+**Step 2** [Optional] Post installation steps to manage Docker as a non-root user. -
+Follow the four steps in this [docker documentation](https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user) to allow managing docker containers without *sudo*. -
-
+If you skip this step, you need to use *sudo* each time you invoke Docker. -**Step 1** Install virtualenv for Ubuntu. +**Step 3** Pull the MXNet docker image. -```bash -$ sudo apt-get update -$ sudo apt-get install -y python-dev python-virtualenv +``` +$ docker pull mxnet/python # Use sudo if you skip Step 2 ``` -**Step 2** Create and activate virtualenv environment for MXNet. +You can list docker images to see if mxnet/python docker image pull was successful. -Following command creates a virtualenv environment at `~/mxnet` directory. However, you can choose any directory by replacing `~/mxnet` with a directory of your choice. +``` +$ docker images # Use sudo if you skip Step 2 -```bash -$ virtualenv --system-site-packages ~/mxnet +REPOSITORY TAG IMAGE ID CREATED SIZE +mxnet/python latest 00d026968b3c 3 weeks ago 1.41 GB ``` -Activate the virtualenv environment created for *MXNet*. +**Step 4** Validate the installation. -```bash -$ source ~/mxnet/bin/activate -``` +
-After activating the environment, you should see the prompt as below. +
+
-```bash -(mxnet)$ -``` +To build from source, refer to the MXNet Ubuntu installation guide. -**Step 3** Install MXNet in the active virtualenv environment. +
-Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command. +
+ -```bash -$ pip install --upgrade pip -``` + +
+
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet +``` +$ pip install mxnet-cu92 ```
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet==1.1.0 +``` +$ pip install mxnet-cu91==1.1.0 ```
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet==1.0.0 +``` +$ pip install mxnet-cu90==1.0.0 ```
-
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet==0.12.1 ``` - -For *MXNet* 0.12.0 - - -```bash -$ pip install mxnet==0.12.0 +$ pip install mxnet-cu90==0.12.1 ```
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet==0.11.0 +``` +$ pip install mxnet-cu80==0.11.0 ```
-Install *MXNet* with OpenBLAS acceleration. - -```bash -$ pip install mxnet --pre +``` +$ pip install mxnet-cu92 --pre ```
+
+Most MXNet versions offer an experimental MKL pip package that will be much faster when running on Intel hardware. +Check the chart below for other options, refer to PyPI for other MXNet pip packages, or validate your MXNet installation. +pip packages -**Step 4** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` +**NOTES:** -**Step 5** Validate the installation by running simple *MXNet* code described [here](#validate-mxnet-installation). +CUDA should be installed first. Instructions can be found in the CUDA dependencies section of the MXNet Ubuntu installation guide. -**Note** You can read more about virtualenv [here](https://virtualenv.pypa.io/en/stable/userguide/). +**Important:** Make sure your installed CUDA version matches the CUDA version in the pip package. Check your CUDA version with the following command: + +``` +nvcc --version +``` -
+You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. +
+
Docker images with *MXNet* are available at [Docker Hub](https://hub.docker.com/r/mxnet/). @@ -385,2146 +272,806 @@ Follow the four steps in this [docker documentation](https://docs.docker.com/eng If you skip this step, you need to use *sudo* each time you invoke Docker. -**Step 3** Pull the MXNet docker image. +**Step 3** Install *nvidia-docker-plugin* following the [installation instructions](https://github.com/NVIDIA/nvidia-docker/wiki/Installation). *nvidia-docker-plugin* is required to enable the usage of GPUs from the docker containers. -```bash -$ docker pull mxnet/python # Use sudo if you skip Step 2 +**Step 4** Pull the MXNet docker image. + +``` +$ docker pull mxnet/python:gpu # Use sudo if you skip Step 2 ``` You can list docker images to see if mxnet/python docker image pull was successful. -```bash +``` $ docker images # Use sudo if you skip Step 2 REPOSITORY TAG IMAGE ID CREATED SIZE -mxnet/python latest 00d026968b3c 3 weeks ago 1.41 GB +mxnet/python gpu 493b2683c269 3 weeks ago 4.77 GB ``` -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +**Step 5** Validate the installation.

+Refer to the MXNet Ubuntu installation guide. -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. Example - Python bindings, Scala 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 -``` +The default version of R that is installed with `apt-get` is insufficient. You will need to first [install R v3.4.4+ and build MXNet from source](ubuntu_setup.html#install-the-mxnet-package-for-r). -**Step 2** Install OpenBLAS. +After you have setup R v3.4.4+ and MXNet, you can build and install the MXNet R bindings with the following, assuming that `incubator-mxnet` is the source directory you used to build MXNet as follows: -*MXNet* uses [BLAS](https://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms) and [LAPACK](https://en.wikipedia.org/wiki/LAPACK) libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK 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 liblapack-dev +``` +$ cd incubator-mxnet +$ make rpkg ``` -**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. You can clone the repository as described in the following code block, or you may try the download links for your desired MXNet version. +
+ +The default version of R that is installed with `apt-get` is insufficient. You will need to first [install R v3.4.4+ and build MXNet from source](ubuntu_setup.html#install-the-mxnet-package-for-r). + +After you have setup R v3.4.4+ and MXNet, you can build and install the MXNet R bindings with the following, assuming that `incubator-mxnet` is the source directory you used to build MXNet as follows: -```bash -$ git clone --recursive https://github.com/apache/incubator-mxnet +``` $ cd incubator-mxnet -$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas +$ make rpkg ``` -*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 the MXNet Python binding** +
+
+
+You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. -**Step 1** Install prerequisites - python, setup-tools, python-pip and libfortran (required for Numpy). +maven badge -```bash -$ sudo apt-get install -y python-dev python-setuptools python-pip libgfortran3 +```html + + org.apache.mxnet + mxnet-full_2.11-linux-x86_64-gpu + ``` +
+
-**Step 2** Install the MXNet Python binding. - -```bash -$ cd python -$ pip install -e . -``` +
+
+You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. -Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. +maven badge -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz +```html + + org.apache.mxnet + mxnet-full_2.11-linux-x86_64-cpu + ``` +
+
+
-**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - - - +
+ +
-
+
+
+
+Refer to the Perl section of the MXNet Ubuntu installation guide. -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: +
+
+
+

To enable the C++ package, build from source using `make USE_CPP_PACKAGE=1`. +
Refer to the MXNet C++ setup guide for more info.

+
+
+
+
+For more installation options, refer to the MXNet Ubuntu installation guide. -1. Install CUDA 9.0 following the NVIDIA's [installation guide](http://docs.nvidia.com/cuda/cuda-installation-guide-linux/). -2. Install cuDNN 7 for CUDA 9.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* + +
+
+
-
- -**Step 1** Install prerequisites - wget and latest pip. - -Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command in the terminal. +
-```bash -$ sudo apt-get update -$ sudo apt-get install -y wget python -$ wget https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py +``` +$ pip install mxnet ``` -
+
-**Step 2** Install *MXNet* with GPU support using CUDA 9.2 -**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: +
-```bash -nvcc --version ``` - -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. - -```bash -$ pip install mxnet-cu92 +$ pip install mxnet==1.1.0 ``` -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +
-**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +
-**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-cu90mkl +``` +$ pip install mxnet==1.0.0 ``` -
- - -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.1 +
-**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: +
-```bash -nvcc --version +``` +$ pip install mxnet=0.12.1 ``` -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. +
-```bash -$ pip install mxnet-cu91==1.1.0 -``` -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +
-**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz ``` +$ pip install mxnet==0.11.0 +``` + +
-**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +
-**Experimental Choice** If You would like to install MXNet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-cu91mkl==1.1.0 +``` +$ pip install mxnet --pre ``` -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +
+
+Most MXNet versions offer an experimental MKL pip package that will be much faster when running on Intel hardware. +Check the chart below for other options, refer to PyPI for other MXNet pip packages, or validate your MXNet installation. -
+pip packages -
+
-**Step 2** Install *MXNet* with GPU support using CUDA 9.0 - -```bash -$ pip install mxnet-cu90==1.0.0 -``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` - -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-cu90mkl==1.0.0 -``` - -
+
+
-
+Docker images with *MXNet* are available at [Docker Hub](https://hub.docker.com/r/mxnet/). -**Step 2** Install *MXNet* with GPU support using CUDA 9.0 +**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac). -```bash -$ pip install mxnet-cu90==0.12.1 -``` +*Note* - You can install Community Edition (CE) to get started with *MXNet*. -For *MXNet* 0.12.0 - +**Step 2** Pull the MXNet docker image. -```bash -$ pip install mxnet-cu90==0.12.0 ``` - -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz +$ docker pull mxnet/python ``` -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +You can list docker images to see if mxnet/python docker image pull was successful. -**Experimental Choice** If You would like to install mxnet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-cu90mkl==0.12.1 ``` +$ docker images -For *MXNet* 0.12.0 - - -```bash -$ pip install mxnet-cu90mkl==0.12.0 +REPOSITORY TAG IMAGE ID CREATED SIZE +mxnet/python latest 00d026968b3c 3 weeks ago 1.41 GB ``` -
- - -
+**Step 4** Validate the installation. -**Step 2** Install *MXNet* with GPU support using CUDA 8.0 +
-```bash -$ pip install mxnet-cu80==0.11.0 -``` -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` +
+
-**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +To build from source, refer to the MXNet macOS installation guide. -**Experimental Choice** If You would like to install MXNet with Intel MKL, try the experimental pip package with MKL: -```bash -$ pip install mxnet-cu80mkl==0.11.0 -``` +MXNet developers should refer to the MXNet wiki's Developer Setup on Mac. +
+
+
-
+ +
+
+
+This option is only available by building from source. Refer to the MXNet macOS installation guide. +
+
-
+
+
-
+Refer to the MXNet macOS installation guide. +MXNet developers should refer to the MXNet wiki's Developer Setup on Mac.
+
+
+
-**Step 1** Install virtualenv for Ubuntu. -```bash -$ sudo apt-get update -$ sudo apt-get install -y python-dev python-virtualenv -``` + -**Step 2** Create and activate virtualenv environment for MXNet. +
+
+
-Following command creates a virtualenv environment at `~/mxnet` directory. However, you can choose any directory by replacing `~/mxnet` with a directory of your choice. +Install the latest version (3.5.1+) of R from [CRAN](https://cran.r-project.org/bin/macosx/). +You can [build MXNet-R from source](osx_setup.html#install-the-mxnet-package-for-r), or you can use a pre-built binary: -```bash -$ virtualenv --system-site-packages ~/mxnet +```r +cran <- getOption("repos") +cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" +options(repos = cran) +install.packages("mxnet") ``` -Activate the virtualenv environment created for *MXNet*. +
-```bash -$ source ~/mxnet/bin/activate -``` -After activating the environment, you should see the prompt as below. +
+
+Will be available soon. -```bash -(mxnet)$ -``` +
+
-**Step 3** Install MXNet in the active virtualenv environment. +
+
+
+You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. -Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command. +maven badge -```bash -(mxnet)$ pip install --upgrade pip +```html + + org.apache.mxnet + mxnet-full_2.11-osx-x86_64-cpu + ``` +
+
+
+Not available at this time.
-
+
+
-**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: -```bash -nvcc --version -``` -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. +
+
+
+Refer to the Julia section of the MXNet macOS installation guide. -Install *MXNet* with GPU support using CUDA 9.2: +
+
-```bash -(mxnet)$ pip install mxnet-cu92 -``` +
+
+
+Refer to the Perl section of the MXNet macOS installation guide. -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +
+
-
-
+
+
+

To enable the C++ package, build from source using `make USE_CPP_PACKAGE=1`. +
Refer to the MXNet C++ setup guide for more info.

+
+
+
+For more installation options, refer to the MXNet macOS installation guide. +
-**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: -```bash -nvcc --version + +
+
+
+
+
+ +``` +$ pip install mxnet ``` -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. +
-Install *MXNet* with GPU support using CUDA 9.1: +
-```bash -(mxnet)$ pip install mxnet-cu91==1.1.0 ``` - -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +$ pip install mxnet==1.1.0 +```
-
-Install *MXNet* with GPU support using CUDA 9.0. - -```bash -(mxnet)$ pip install mxnet-cu90==1.0.0 ``` -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +$ pip install mxnet==1.0.0 +```
-
-Install *MXNet* with GPU support using CUDA 9.0. - -```bash -(mxnet)$ pip install mxnet-cu90==0.12.1 ``` - -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). +$ pip install mxnet==0.12.1 +```
-
-Install *MXNet* with GPU support using CUDA 8.0. - -```bash -(mxnet)$ pip install mxnet-cu80==0.11.0 +``` +$ pip install mxnet==0.11.0 ```
-**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: - -```bash -nvcc --version ``` - -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. - -Install *MXNet* with GPU support using CUDA 9.2. - -```bash -(mxnet)$ pip install mxnet-cu92 --pre +$ pip install mxnet --pre ``` -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). -
+
+Most MXNet versions offer an experimental MKL pip package that will be much faster when running on Intel hardware. +Check the chart below for other options, refer to PyPI for other MXNet pip packages, or validate your MXNet installation. -**Step 4** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` - -**Step 5** Validate the installation by running simple *MXNet* code described [here](#validate-mxnet-installation). +pip packages -**Note** You can read more about virtualenv [here](https://virtualenv.pypa.io/en/stable/userguide/). -
+
-
+

-Docker images with *MXNet* are available at [Docker Hub](https://hub.docker.com/r/mxnet/). +Refer to the MXNet Windows installation guide. -**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository). -*Note* - You can install Community Edition (CE) to get started with *MXNet*. +
+
-**Step 2** [Optional] Post installation steps to manage Docker as a non-root user. -Follow the four steps in this [docker documentation](https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user) to allow managing docker containers without *sudo*. +
+
+
-If you skip this step, you need to use *sudo* each time you invoke Docker. +``` +$ pip install mxnet-cu92 +``` -**Step 3** Install *nvidia-docker-plugin* following the [installation instructions](https://github.com/NVIDIA/nvidia-docker/wiki/Installation). *nvidia-docker-plugin* is required to enable the usage of GPUs from the docker containers. +
-**Step 4** Pull the MXNet docker image. +
-```bash -$ docker pull mxnet/python:gpu # Use sudo if you skip Step 2 +``` +$ pip install mxnet-cu91==1.1.0 ``` -You can list docker images to see if mxnet/python docker image pull was successful. +
-```bash -$ docker images # Use sudo if you skip Step 2 +
-REPOSITORY TAG IMAGE ID CREATED SIZE -mxnet/python gpu 493b2683c269 3 weeks ago 4.77 GB +``` +$ pip install mxnet-cu90==1.0.0 ``` -**Step 5** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +
-
+
-
+``` +$ pip install mxnet-cu90==0.12.1 +``` -
+
-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. Example - Python bindings, Scala 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/) +``` +$ pip install mxnet-cu80==0.11.0 +``` -
+
-**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) and [LAPACK](https://en.wikipedia.org/wiki/LAPACK) libraries for accelerated numerical computations on CPU machine. There are several flavors of BLAS/LAPACK 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 liblapack-dev +$ pip install mxnet-cu92 --pre ``` -**Step 3** Install OpenCV. +
+
+Most MXNet versions offer an experimental MKL pip package that will be much faster when running on Intel hardware. +Check the chart below for other options, refer to PyPI for other MXNet pip packages, or validate your MXNet installation. -*MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations. -```bash -$ sudo apt-get install -y libopencv-dev -``` +pip packages -**Step 4** Download MXNet sources and build MXNet core shared library. You can clone the repository as described in the following code block, or you may try the download links for your desired MXNet version. +**NOTES:** -```bash -$ git clone --recursive https://github.com/apache/incubator-mxnet -$ cd incubator-mxnet -$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1 -``` +[Anaconda](https://www.anaconda.com/download/) is recommended. -*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*. +CUDA should be installed first. Instructions can be found in the CUDA dependencies section of the MXNet Ubuntu installation guide. -
+**Important:** Make sure your installed CUDA version matches the CUDA version in the pip package. Check your CUDA version with the following command: -**Install the MXNet Python binding** +``` +nvcc --version +``` -**Step 1** Install prerequisites - python, setup-tools, python-pip and libfortran (required for Numpy).. +Refer to [#8671](https://github.com/apache/incubator-mxnet/issues/8671) for status on CUDA 9.1 support. -```bash -$ sudo apt-get install -y python-dev python-setuptools python-pip libgfortran3 -``` +You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. -**Step 2** Install the MXNet Python binding. +
-```bash -$ cd python -$ pip install -e . -``` +
+
-Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. +To build from source, refer to the MXNet Windows installation guide. -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -sudo apt-get install graphviz -pip install graphviz -``` -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +
+
+
-
-
- - +
+
-The default version of R that is installed with `apt-get` is insufficient. You will need to first [install R v3.4.4+ and build MXNet from source](ubuntu_setup.html#install-the-mxnet-package-for-r). - -After you have setup R v3.4.4+ and MXNet, you can build and install the MXNet R bindings with the following, assuming that `incubator-mxnet` is the source directory you used to build MXNet as follows: +Install the latest version (3.5.1+) of R from [CRAN](https://cran.r-project.org/bin/windows/). +You can [build MXNet-R from source](windows_setup.html#install-mxnet-package-for-r), or you can use a pre-built binary: -```bash -$ cd incubator-mxnet -$ make rpkg +```r +cran <- getOption("repos") +cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" +options(repos = cran) +install.packages("mxnet") ``` -
- +
+
-The default version of R that is installed with `apt-get` is insufficient. You will need to first [install R v3.4.4+ and build MXNet from source](ubuntu_setup.html#install-the-mxnet-package-for-r). - -After you have setup R v3.4.4+ and MXNet, you can build and install the MXNet R bindings with the following, assuming that `incubator-mxnet` is the source directory you used to build MXNet as follows: +You can [build MXNet-R from source](windows_setup.html#install-mxnet-package-for-r), or you can use a pre-built binary: -```bash -$ cd incubator-mxnet -$ make rpkg +```r + cran <- getOption("repos") + cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/GPU/cu92" + options(repos = cran) + install.packages("mxnet") ``` +Change cu92 to cu80, cu90 or cu91 based on your CUDA toolkit version. Currently, MXNet supports these versions of CUDA.
- - +
-
- -You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. - -maven badge - -```html - - org.apache.mxnet - mxnet-full_2.11-linux-x86_64-gpu - -``` -
-
- -
- -You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. - -maven badge - -```html - - org.apache.mxnet - mxnet-full_2.11-linux-x86_64-cpu - -``` -
-
+
+
+MXNet-Scala for Windows is not yet available. +
+
- -
+
- -Follow the installation instructions [in this guide](./ubuntu_setup.md) to set up MXNet. +
+Refer to the Julia section of the MXNet Windows installation guide.
-
+
+ +
+ +
-

To build the C++ package, please refer to this guide.

+
+

To enable the C++ package, build from source using `make USE_CPP_PACKAGE=1`. +
Refer to the MXNet C++ setup guide for more info.


-
- - - - - -
-
-
- -The following installation instructions have been tested on OSX Sierra and El Capitan. +
+
+For more installation options, refer to the MXNet Windows installation guide. +
-
-
+ -**Step 1** Install prerequisites - Homebrew, python development tools. +
-```bash -# Install Homebrew -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -$ export PATH=/usr/local/bin:/usr/local/sbin:$PATH +AWS Marketplace distributes Deep Learning AMIs (Amazon Machine Image) with MXNet pre-installed. You can launch one of these Deep Learning AMIs by following instructions in the [AWS Deep Learning AMI Developer Guide](http://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html). -# Install python development tools - python2.7, pip, python-setuptools -$ brew install python -``` +You can also run distributed deep learning with *MXNet* on AWS using [Cloudformation Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md). -**Step 2** Install MXNet with OpenBLAS acceleration. +
-Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command. -```bash -$ pip install --upgrade pip -$ pip install --upgrade setuptools -``` + +
+
-
+MXNet supports the Debian based Raspbian ARM based operating system so you can run MXNet on Raspberry Pi Devices. -Then use pip to install MXNet: +These instructions will walk through how to build MXNet for the Raspberry Pi and install the Python bindings for the library. -```bash -$ pip install mxnet -``` -
+You can do a dockerized cross compilation build on your local machine or a native build on-device. +The complete MXNet library and its requirements can take almost 200MB of RAM, and loading large models with the library can take over 1GB of RAM. Because of this, we recommend running MXNet on the Raspberry Pi 3 or an equivalent device that has more than 1 GB of RAM and a Secure Digital (SD) card that has at least 4 GB of free memory. -
+**Cross compilation build (Experimental)** -Then use pip to install MXNet: +## Docker installation +**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository). -```bash -$ pip install mxnet==1.1.0 -``` +*Note* - You can install Community Edition (CE) -
+**Step 2** [Optional] Post installation steps to manage Docker as a non-root user. +Follow the four steps in this [docker documentation](https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user) to allow managing docker containers without *sudo*. -
+## Build -Then use pip to install MXNet: +The following command will build a container with dependencies and tools and then compile MXNet for +ARMv7. The resulting artifact will be located in `build/mxnet-x.x.x-py2.py3-none-any.whl`, copy this +file to your Raspberry Pi. -```bash -$ pip install mxnet==1.0.0 +``` +ci/build.py -p armv7 ``` -
- -
+## Install -Then use pip to install MXNet: +Create a virtualenv and install the package we created previously. -```bash -$ pip install mxnet=0.12.1 ``` - -For MXNet 0.12.0 - - -```bash -$ pip install mxnet=0.12.0 +virtualenv -p `which python3` mxnet_py3 +source mxnet_py3/bin/activate +pip install mxnet-x.x.x-py2.py3-none-any.whl ``` -
- - -
- -Then use pip to install MXNet: - -```bash -$ pip install mxnet==0.11.0 -``` +**Native Build** -
+Installing MXNet is a two-step process: -
+1. Build the shared library from the MXNet C++ source code. +2. Install the supported language-specific packages for MXNet. -Then use pip to install MXNet: +**Step 1** Build the Shared Library -```bash -$ pip install mxnet --pre -``` +On Raspbian versions Wheezy and later, you need the following dependencies: -
+- Git (to pull code from GitHub) -**Step 3** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -$ brew install graphviz -$ pip install graphviz -``` +- libblas (for linear algebraic operations) -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). +- libopencv (for computer vision operations. This is optional if you want to save RAM and Disk Space) -
+- A C++ compiler that supports C++ 11. The C++ compiler compiles and builds MXNet source code. Supported compilers include the following: + - [G++ (4.8 or later)](https://gcc.gnu.org/gcc-4.8/). Make sure to use gcc 4 and not 5 or 6 as there are known bugs with these compilers. + - [Clang (3.9 - 6)](https://clang.llvm.org/) -
-
+Install these dependencies using the following commands in any directory: -**Step 1** Install prerequisites - Homebrew, python development tools. +``` + sudo apt-get update + sudo apt-get -y install git cmake ninja-build build-essential g++-4.9 c++-4.9 liblapack* libblas* libopencv* libopenblas* python3-dev virtualenv +``` -```bash -# Install Homebrew -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -$ export PATH=/usr/local/bin:/usr/local/sbin:$PATH +Clone the MXNet source code repository using the following `git` command in your home directory: +``` + git clone https://github.com/apache/incubator-mxnet.git --recursive + cd incubator-mxnet +``` -# Install python development tools - python2.7, pip, python-setuptools -$ brew install python +Build: +``` + mkdir -p build && cd build + cmake \ + -DUSE_SSE=OFF \ + -DUSE_CUDA=OFF \ + -DUSE_OPENCV=ON \ + -DUSE_OPENMP=ON \ + -DUSE_MKL_IF_AVAILABLE=OFF \ + -DUSE_SIGNAL_HANDLER=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -GNinja .. + ninja -j$(nproc) ``` +Some compilation units require memory close to 1GB, so it's recommended that you enable swap as +explained below and be cautious about increasing the number of jobs when building (-j) -**Step 2** Install virtualenv for macOS. +Executing these commands start the build process, which can take up to a couple hours, and creates a file called `libmxnet.so` in the build directory. -```bash -$ pip install virtualenv +If you are getting build errors in which the compiler is being killed, it is likely that the +compiler is running out of memory (especially if you are on Raspberry Pi 1, 2 or Zero, which have +less than 1GB of RAM), this can often be rectified by increasing the swapfile size on the Pi by +editing the file /etc/dphys-swapfile and changing the line CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024, +then running: +``` + sudo /etc/init.d/dphys-swapfile stop + sudo /etc/init.d/dphys-swapfile start + free -m # to verify the swapfile size has been increased ``` -**Step 3** Create and activate virtualenv environment for MXNet. +**Step 2** Install MXNet Python Bindings -Following command creates a virtualenv environment at `~/mxnet` directory. However, you can choose any directory by replacing `~/mxnet` with a directory of your choice. +To install Python bindings run the following commands in the MXNet directory: -```bash -$ virtualenv --system-site-packages ~/mxnet ``` - -Activate the virtualenv environment created for *MXNet*. - -```bash -$ source ~/mxnet/bin/activate + cd python + pip install --upgrade pip + pip install -e . ``` -After activating the environment, you should see the prompt as below. +Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. -```bash -(mxnet)$ +Alternatively you can create a whl package installable with pip with the following command: +``` +ci/docker/runtime_functions.sh build_wheel python/ $(realpath build) ``` -**Step 4** Install MXNet in the active virtualenv environment. -Installing *MXNet* with pip requires a latest version of `pip`. Install the latest version of `pip` by issuing the following command. +You are now ready to run MXNet on your Raspberry Pi device. You can get started by following the tutorial on [Real-time Object Detection with MXNet On The Raspberry Pi](http://mxnet.io/tutorials/embedded/wine_detector.html). -```bash -(mxnet)$ pip install --upgrade pip -(mxnet)$ pip install --upgrade setuptools -``` +*Note - Because the complete MXNet library takes up a significant amount of the Raspberry Pi's limited RAM, when loading training data or large models into memory, you might have to turn off the GUI and terminate running processes to free RAM.* -
+
-Install *MXNet* with OpenBLAS acceleration. -```bash -(mxnet)$ pip install mxnet -``` +
-
+# Nvidia Jetson TX family -
+MXNet supports the Ubuntu Arch64 based operating system so you can run MXNet on NVIDIA Jetson Devices. -Install *MXNet* with OpenBLAS acceleration. +These instructions will walk through how to build MXNet for the Pascal based [NVIDIA Jetson TX2](http://www.nvidia.com/object/embedded-systems-dev-kits-modules.html) and install the corresponding python language bindings. -```bash -(mxnet)$ pip install mxnet==1.1.0 -``` +For the purposes of this install guide we will assume that CUDA is already installed on your Jetson device. -
+**Install MXNet** -
+Installing MXNet is a two-step process: -Install *MXNet* with OpenBLAS acceleration. +1. Build the shared library from the MXNet C++ source code. +2. Install the supported language-specific packages for MXNet. -```bash -(mxnet)$ pip install mxnet==1.0.0 -``` +**Step 1** Build the Shared Library -
+You need the following additional dependencies: +- Git (to pull code from GitHub) -
+- libatlas (for linear algebraic operations) -Install *MXNet* with OpenBLAS acceleration. +- libopencv (for computer vision operations) -```bash -(mxnet)$ pip install mxnet==0.12.1 -``` +- python pip (to load relevant python packages for our language bindings) -For *MXNet* 0.12.0 - +Install these dependencies using the following commands in any directory: -```bash -(mxnet)$ pip install mxnet==0.12.0 +``` + sudo apt-get update + sudo apt-get -y install git build-essential libatlas-base-dev libopencv-dev graphviz python-pip + sudo pip install pip --upgrade + sudo pip install setuptools numpy --upgrade + sudo pip install graphviz jupyter ``` +Clone the MXNet source code repository using the following `git` command in your home directory: +``` + git clone https://github.com/apache/incubator-mxnet.git --recursive + cd incubator-mxnet +``` -
- -
+Edit the Makefile to install the MXNet with CUDA bindings to leverage the GPU on the Jetson: +``` + cp make/crosscompile.jetson.mk config.mk +``` -Install *MXNet* with OpenBLAS acceleration. +Edit the Mshadow Makefile to ensure MXNet builds with Pascal's hardware level low precision acceleration by editing 3rdparty/mshadow/make/mshadow.mk and adding the following after line 122: +``` +MSHADOW_CFLAGS += -DMSHADOW_USE_PASCAL=1 +``` -```bash -(mxnet)$ pip install mxnet==0.11.0 +Now you can build the complete MXNet library with the following command: +``` + make -j $(nproc) ``` -
+Executing this command creates a file called `libmxnet.so` in the mxnet/lib directory. -
+**Step 2** Install MXNet Python Bindings -Install *MXNet* with OpenBLAS acceleration. +To install Python bindings run the following commands in the MXNet directory: -```bash -(mxnet)$ pip install mxnet --pre ``` - -
- - -**Step 5** Install [Graphviz](http://www.graphviz.org/). (Optional, needed for graph visualization using `mxnet.viz` package). -```bash -$ brew install graphviz -(mxnet)$ pip install graphviz + cd python + pip install --upgrade pip + pip install -e . ``` -**Step 6** Validate the installation by running simple *MXNet* code described [here](#validate-mxnet-installation). - -**Note** You can read more about virtualenv [here](https://virtualenv.pypa.io/en/stable/userguide/). +Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. -
+Add the mxnet folder to the path: +``` + cd .. + export MXNET_HOME=$(pwd) + echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.rc + source ~/.rc +``` -
-
+You are now ready to run MXNet on your NVIDIA Jetson TX2 device. -Docker images with *MXNet* are available at [Docker Hub](https://hub.docker.com/r/mxnet/). +
+
-**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac). -*Note* - You can install Community Edition (CE) to get started with *MXNet*. + -**Step 2** Pull the MXNet docker image. -```bash -$ docker pull mxnet/python -``` - -You can list docker images to see if mxnet/python docker image pull was successful. - -```bash -$ docker images - -REPOSITORY TAG IMAGE ID CREATED SIZE -mxnet/python latest 00d026968b3c 3 weeks ago 1.41 GB -``` - -**Step 4** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -
- - -
-
- -**Prerequisites** - -If not already installed, [download and install Xcode](https://developer.apple.com/xcode/) (or [insall it from the App Store](https://itunes.apple.com/us/app/xcode/id497799835)) for macOS. [Xcode](https://en.wikipedia.org/wiki/Xcode) is an integrated development environment for macOS containing a suite of software development tools like C/C++ compilers, BLAS library and more. - -
- -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. Example - Python bindings, Scala bindings. - -Make sure you have installed Xcode before proceeding further. - -
- -All the instructions to build *MXNet* core shared library and *MXNet* Python bindings are compiled as one helper *bash* script. You can use [this bash script](https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-osx-python.sh) to build *MXNet* for Python, from source, on macOS. - -**Step 1** Download the bash script for building MXNet from source. - -```bash -$ curl -O https://raw.githubusercontent.com/dmlc/mxnet/master/setup-utils/install-mxnet-osx-python.sh -``` - -**Step 2** Run the script to get latest MXNet source and build. - -```bash -# Make the script executable -$ chmod 744 install-mxnet-osx-python.sh - -# Run the script. It takes around 5 mins. -$ bash install-mxnet-osx-python.sh -``` - -**Step 3** Validate the installation by running simple MXNet code described [here](#validate-mxnet-installation). - -
-
- - - -
-
-
- -Try the **Build from Source** option for now. - -
- -
- -**Step 1** Install prerequisites - Homebrew, python development tools. - -```bash -# Install Homebrew -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -$ export PATH=/usr/local/bin:/usr/local/sbin:$PATH - -# Install python development tools - python2.7, pip, python-setuptools -$ brew install python pkg-config graphviz -``` - -**Step 2** Install optional components - OpenCV - -If you want to use OpenCV you should install it first, then build MXNet with the `USE_OPENCV=1` option in the later steps. - -```bash -brew tap homebrew/science -brew install opencv - -``` - -**Step 3** Install CUDA and cuDNN - -The following instructions are for CUDA 9.1 and cuDNN 7 for macOS 10.12+ and a CUDA-capable GPU. They summarize confirmed successful builds in [#9217](https://github.com/apache/incubator-mxnet/issues/9217). -Alternatively, you may follow the [CUDA installation instructions for macOS](https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html). - -1. [Download Xcode 8.3.3 from Apple](https://developer.apple.com/download/more/). This is the version [NVIDIA specifies in its instructions for macOS](https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html). Unzip and rename to `Xcode8.3.3.app`. - -2. Run `sudo xcode-select -s /Applications/Xcode8.3.3.app` or to wherever you have placed Xcode. - -3. Run `xcode-select --install` to install all command line tools, compilers, etc. - -4. Run `sudo xcodebuild -license accept` to accept Xcode's licensing terms. - -5. Install CUDA for macOS. Specific steps are provided in NVIDIA's [CUDA installation instructions](https://docs.nvidia.com/cuda/cuda-installation-guide-mac-os-x/index.html#installation). - -6. [Download](http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#download-mac) and [install](http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installmac) cuDNN for macOS. You will need to [create a free developer account](https://developer.nvidia.com/accelerated-computing-developer) with NVIDIA prior to getting the download link. - -**Step 4** Build MXNet - -1. Run `git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet` to get the latest version. - -2. Run `cd mxnet`. - -3. Edit the `make/osx.mk` file to set the following parameters: - - ``` - USE_CUDA = 1 - USE_CUDA_PATH = /usr/local/cuda - USE_CUDNN = 1 - USE_OPENCV = 0 # set to 1 if you want to build with OpenCV - ``` - -4. Copy the `make/osx.mk` to `config.mk` - -5. Run `make`. If you previously attempted to compile you might want to do `make clean_all` first. You can also run `make -j` with the number of processors you have to compile with multithreading. There'll be plenty of warnings, but there should be no errors. - -6. Once finished, you should have a file called `libmxnet.so` in `lib/`. - -7. Do `cd python`. - -8. Run `sudo pip install -e .` **Note**: the `.` is part of the command. - -
-
- - - - - -
-
- -Install the latest version (3.5.1+) of R from [CRAN](https://cran.r-project.org/bin/macosx/). -You can [build MXNet-R from source](osx_setup.html#install-the-mxnet-package-for-r), or you can use a pre-built binary: - -```r -cran <- getOption("repos") -cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" -options(repos = cran) -install.packages("mxnet") -``` - -
- - -
- -Will be available soon. - -
-
- -
-
- -You can use the Maven packages defined in the following `dependency` to include MXNet in your Scala project. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process. - -maven badge - -```html - - org.apache.mxnet - mxnet-full_2.11-osx-x86_64-cpu - -``` -
-
-
- -Not available at this time.
- -
-
- - -
-
- -Follow the installation instructions [in this guide](./osx_setup.md) to set up MXNet. - -
-
- - -
-

To build the C++ package, please refer to this guide.

-
-
- - - - - - - - - - -
-
-
-
- -
- -**Step 1** Install Python. - -[Anaconda](https://www.anaconda.com/download/) is recommended. - -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet -``` - -
- -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet==1.1.0 -``` - -
- -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet==1.0.0 -``` - -
- - -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet==0.12.1 -``` - -For *MXNet* 0.12.0 - - -```bash -$ pip install mxnet==0.12.0 -``` - - -
- -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet==0.11.0 -``` - - -
- -
- -**Step 2** Install *MXNet*. - -```bash -$ pip install mxnet --pre -``` - -
- - -
- - -
- -Follow the installation instructions [in this guide](./windows_setup.md) to set up MXNet. - -
-
- - -
-
- -
- -**Step 1** Install Python. - -[Anaconda](https://www.anaconda.com/download/) is recommended. - - -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.2. - -**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: - -```bash -nvcc --version -``` - -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. - -```bash -$ pip install mxnet-cu92 -``` - -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). - -
- -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.1. - -**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: - -```bash -nvcc --version -``` - -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. - -```bash -$ pip install mxnet-cu91==1.1.0 -``` - -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). - -
- -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.0. - -```bash -$ pip install mxnet-cu90==1.0.0 -``` - -
- -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.0. - -```bash -$ pip install mxnet-cu90==0.12.1 -``` - -Install *MXNet* 0.12.0 with GPU support using CUDA 9.0. - -```bash -$ pip install mxnet-cu90==0.12.0 -``` - -
- -
- -**Step 2** Install *MXNet* with GPU support using CUDA 8.0. - -```bash -$ pip install mxnet-cu80==0.11.0 -``` - -
- -
- -**Step 2** Install *MXNet* with GPU support using CUDA 9.2. - -**Important**: Make sure your installed CUDA version matches the CUDA version in the pip package. -Check your CUDA version with the following command: - -```bash -nvcc --version -``` - -You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version. - -```bash -$ pip install mxnet-cu92 --pre -``` - -Refer to [pypi for older packages](https://pypi.org/project/mxnet/). - -
- -Refer to [#8671](https://github.com/apache/incubator-mxnet/issues/8671) for status on CUDA 9.1 support. - -
-
-
- -We provide both options to build and install MXNet yourself using [Microsoft Visual Studio 2017](https://www.visualstudio.com/downloads/), and [Microsoft Visual Studio 2015](https://www.visualstudio.com/vs/older-downloads/). - -**Option 1** - -To build and install MXNet yourself using [Microsoft Visual Studio 2017](https://www.visualstudio.com/downloads/), you need the following dependencies. Install the required dependencies: - -1. If [Microsoft Visual Studio 2017](https://www.visualstudio.com/downloads/) is not already installed, download and install it. You can download and install the free community edition. -2. Download and install [CMake](https://cmake.org/files/v3.11/cmake-3.11.0-rc4-win64-x64.msi) if it is not already installed. -3. Download and install [OpenCV](https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.4.1/opencv-3.4.1-vc14_vc15.exe/download). -4. Unzip the OpenCV package. -5. Set the environment variable ```OpenCV_DIR``` to point to the ```OpenCV build directory``` (e.g., ```OpenCV_DIR = C:\utils\opencv\build```). -6. If you don’t have the Intel Math Kernel Library (MKL) installed, download and install [OpenBlas](https://sourceforge.net/projects/openblas/files/v0.2.20/OpenBLAS%200.2.20%20version.zip/download). -7. Set the environment variable ```OpenBLAS_HOME``` to point to the ```OpenBLAS``` directory that contains the ```include``` and ```lib``` directories (e.g., ```OpenBLAS_HOME = C:\utils\OpenBLAS```). -8. Download and install CUDA: Install [CUDA](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal), and Download the base installer (e.g., ```cuda_9.1.85_win10.exe```). -9. Download and install cuDNN. To get access to the download link, register as an NVIDIA community user. Then Follow the [link](http://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#install-windows) to install the cuDNN. -10. Download and install [git](https://git-for-windows.github.io/). - -After you have installed all of the required dependencies, build the MXNet source code: - -1. Start ```cmd``` in windows. - -2. Download the MXNet source code from GitHub by using following command: - -```r -cd C:\ -git clone https://github.com/apache/incubator-mxnet.git --recursive -``` - -3. Follow [this link](https://docs.microsoft.com/en-us/visualstudio/install/modify-visual-studio) to modify ```Individual components```, and check ```VC++ 2017 version 15.4 v14.11 toolset```, and click ```Modify```. - -4. Change the version of the Visual studio 2017 to v14.11 using the following command (by default the VS2017 is installed in the following path): - -```r -"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.11 -``` - -5. Create a build dir using the following command and go to the directory, for example: - -```r -mkdir C:\build -cd C:\build -``` - -6. CMake the MXNet source code by using following command: - -```r -cmake -G "Visual Studio 15 2017 Win64" -T cuda=9.1,host=x64 -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_LIST=Common -DCUDA_TOOLSET=9.1 -DCUDNN_INCLUDE=C:\cuda\include -DCUDNN_LIBRARY=C:\cuda\lib\x64\cudnn.lib "C:\incubator-mxnet" -``` - -NOTE: make sure the DCUDNN_INCLUDE and DCUDNN_LIBRARY pointing to the “include” and “cudnn.lib” of your CUDA installed location, and the ```C:\incubator-mxnet``` is the location of the source code you just git in the previous step - -7. After the CMake successfully completed, compile the the MXNet source code by using following command: - -```r -msbuild mxnet.sln /p:Configuration=Release;Platform=x64 /maxcpucount -``` - -**Option 2** - -To build and install MXNet yourself using [Microsoft Visual Studio 2015](https://www.visualstudio.com/vs/older-downloads/), you need the following dependencies. Install the required dependencies: - -1. If [Microsoft Visual Studio 2015](https://www.visualstudio.com/vs/older-downloads/) is not already installed, download and install it. You can download and install the free community edition. At least Update 3 of Microsoft Visual Studio 2015 is required to build MXNet from source. Upgrade via it's ```Tools -> Extensions and Updates... | Product Updates``` menu. -2. Download and install [CMake](https://cmake.org/) if it is not already installed. -3. Download and install [OpenCV](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/download). -4. Unzip the OpenCV package. -5. Set the environment variable ```OpenCV_DIR``` to point to the ```OpenCV build directory``` (```C:\opencv\build\x64\vc14``` for example). Also, you need to add the OpenCV bin directory (```C:\opencv\build\x64\vc14\bin``` for example) to the ``PATH`` variable. -6. If you don't have the Intel Math Kernel Library (MKL) installed, download and install [OpenBlas](http://sourceforge.net/projects/openblas/files/v0.2.14/). -7. Set the environment variable ```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\```. -8. Download and install [CUDA](https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64) and [cuDNN](https://developer.nvidia.com/cudnn). To get access to the download link, register as an NVIDIA community user. -9. Set the environment variable ```CUDACXX``` to point to the ```CUDA Compiler```(```C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe``` for example). -10. Set the environment variable ```CUDNN_ROOT``` to point to the ```cuDNN``` directory that contains the ```include```, ```lib``` and ```bin``` directories (```C:\Downloads\cudnn-9.1-windows7-x64-v7\cuda``` for example). - -After you have installed all of the required dependencies, build the MXNet source code: - -1. Download the MXNet source code from [GitHub](https://github.com/apache/incubator-mxnet) (make sure you also download third parties submodules e.g. ```git clone --recurse-submodules```). -2. Use [CMake](https://cmake.org/) to create a Visual Studio solution in ```./build```. -3. In Visual Studio, open the solution file,```.sln```, and compile it. -These commands produce a library called ```mxnet.dll``` in the ```./build/Release/``` or ```./build/Debug``` folder. - -  -Next, we install the ```graphviz``` library that we use for visualizing network graphs that you build on MXNet. We will also install [Jupyter Notebook](http://jupyter.readthedocs.io/) which is used for running MXNet tutorials and examples. -- Install the ```graphviz``` by downloading the installer from the [Graphviz Download Page](https://graphviz.gitlab.io/_pages/Download/Download_windows.html). -**Note** Make sure to add the `graphviz` executable path to the PATH environment variable. Refer [here for more details](http://stackoverflow.com/questions/35064304/runtimeerror-make-sure-the-graphviz-executables-are-on-your-systems-path-aft) - - -  -
-
-
- - - - -
-
- -Install the latest version (3.5.1+) of R from [CRAN](https://cran.r-project.org/bin/windows/). -You can [build MXNet-R from source](windows_setup.html#install-mxnet-package-for-r), or you can use a pre-built binary: - -```r -cran <- getOption("repos") -cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" -options(repos = cran) -install.packages("mxnet") -``` - -
- -
- -You can [build MXNet-R from source](windows_setup.html#install-mxnet-package-for-r), or you can use a pre-built binary: - -```r - cran <- getOption("repos") - cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/GPU/cu92" - options(repos = cran) - install.packages("mxnet") -``` -Change cu92 to cu80, cu90 or cu91 based on your CUDA toolkit version. Currently, MXNet supports these versions of CUDA. - -
-
- -
-
- -MXNet-Scala for Windows is not yet available. -
-
-
- -
-
- -Follow the installation instructions [in this guide](./windows_setup.md) to set up MXNet. - -
-
- -
-
-

To build the C++ package, please refer to this guide.

-
-
-
-
- - - - -
- -AWS Marketplace distributes Deep Learning AMIs (Amazon Machine Image) with MXNet pre-installed. You can launch one of these Deep Learning AMIs by following instructions in the [AWS Deep Learning AMI Developer Guide](http://docs.aws.amazon.com/dlami/latest/devguide/what-is-dlami.html). - -You can also run distributed deep learning with *MXNet* on AWS using [Cloudformation Template](https://github.com/awslabs/deeplearning-cfn/blob/master/README.md). - -
- - - -
-
- -MXNet supports the Debian based Raspbian ARM based operating system so you can run MXNet on Raspberry Pi Devices. - -These instructions will walk through how to build MXNet for the Raspberry Pi and install the Python bindings for the library. - -You can do a dockerized cross compilation build on your local machine or a native build on-device. - -The complete MXNet library and its requirements can take almost 200MB of RAM, and loading large models with the library can take over 1GB of RAM. Because of this, we recommend running MXNet on the Raspberry Pi 3 or an equivalent device that has more than 1 GB of RAM and a Secure Digital (SD) card that has at least 4 GB of free memory. - -**Cross compilation build (Experimental)** - -## Docker installation -**Step 1** Install Docker on your machine by following the [docker installation instructions](https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository). - -*Note* - You can install Community Edition (CE) - -**Step 2** [Optional] Post installation steps to manage Docker as a non-root user. - -Follow the four steps in this [docker documentation](https://docs.docker.com/engine/installation/linux/linux-postinstall/#manage-docker-as-a-non-root-user) to allow managing docker containers without *sudo*. - -## Build - -The following command will build a container with dependencies and tools and then compile MXNet for -ARMv7. The resulting artifact will be located in `build/mxnet-x.x.x-py2.py3-none-any.whl`, copy this -file to your Raspberry Pi. - -```bash -ci/build.py -p armv7 -``` - -## Install - -Create a virtualenv and install the package we created previously. - -```bash -virtualenv -p `which python3` mxnet_py3 -source mxnet_py3/bin/activate -pip install mxnet-x.x.x-py2.py3-none-any.whl -``` - - -**Native Build** - -Installing MXNet is a two-step process: - -1. Build the shared library from the MXNet C++ source code. -2. Install the supported language-specific packages for MXNet. - -**Step 1** Build the Shared Library - -On Raspbian versions Wheezy and later, you need the following dependencies: - -- Git (to pull code from GitHub) - -- libblas (for linear algebraic operations) - -- libopencv (for computer vision operations. This is optional if you want to save RAM and Disk Space) - -- A C++ compiler that supports C++ 11. The C++ compiler compiles and builds MXNet source code. Supported compilers include the following: - -- [G++ (4.8 or later)](https://gcc.gnu.org/gcc-4.8/). Make sure to use gcc 4 and not 5 or 6 as there - are known bugs with these compilers. - -Install these dependencies using the following commands in any directory: - -```bash - sudo apt-get update - sudo apt-get -y install git cmake ninja-build build-essential g++-4.9 c++-4.9 liblapack* libblas* libopencv* libopenblas* python3-dev virtualenv -``` - -Clone the MXNet source code repository using the following `git` command in your home directory: -```bash - git clone https://github.com/apache/incubator-mxnet.git --recursive - cd incubator-mxnet -``` - -Build: -```bash - mkdir -p build && cd build - cmake \ - -DUSE_SSE=OFF \ - -DUSE_CUDA=OFF \ - -DUSE_OPENCV=ON \ - -DUSE_OPENMP=ON \ - -DUSE_MKL_IF_AVAILABLE=OFF \ - -DUSE_SIGNAL_HANDLER=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -GNinja .. - ninja -j1 -``` -Some compilation units require memory close to 1GB, so it's recommended that you enable swap as -explained below and be cautious about increasing the number of jobs when building (-j) - -Executing these commands start the build process, which can take up to a couple hours, and creates a file called `libmxnet.so` in the build directory. - -If you are getting build errors in which the compiler is being killed, it is likely that the -compiler is running out of memory (especially if you are on Raspberry Pi 1, 2 or Zero, which have -less than 1GB of RAM), this can often be rectified by increasing the swapfile size on the Pi by -editing the file /etc/dphys-swapfile and changing the line CONF_SWAPSIZE=100 to CONF_SWAPSIZE=1024, -then running: -```bash - sudo /etc/init.d/dphys-swapfile stop - sudo /etc/init.d/dphys-swapfile start - free -m # to verify the swapfile size has been increased -``` - -**Step 2** Install MXNet Python Bindings - -To install Python bindings run the following commands in the MXNet directory: - -```bash - cd python - pip install --upgrade pip - pip install -e . -``` - -Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. - -Alternatively you can create a whl package installable with pip with the following command: -```bash -ci/docker/runtime_functions.sh build_wheel python/ $(realpath build) -``` - - -You are now ready to run MXNet on your Raspberry Pi device. You can get started by following the tutorial on [Real-time Object Detection with MXNet On The Raspberry Pi](http://mxnet.io/tutorials/embedded/wine_detector.html). - -*Note - Because the complete MXNet library takes up a significant amount of the Raspberry Pi's limited RAM, when loading training data or large models into memory, you might have to turn off the GUI and terminate running processes to free RAM.* - -
- - -
- -# Nvidia Jetson TX family - -MXNet supports the Ubuntu Arch64 based operating system so you can run MXNet on NVIDIA Jetson Devices. - -These instructions will walk through how to build MXNet for the Pascal based [NVIDIA Jetson TX2](http://www.nvidia.com/object/embedded-systems-dev-kits-modules.html) and install the corresponding python language bindings. - -For the purposes of this install guide we will assume that CUDA is already installed on your Jetson device. - -**Install MXNet** - -Installing MXNet is a two-step process: - -1. Build the shared library from the MXNet C++ source code. -2. Install the supported language-specific packages for MXNet. - -**Step 1** Build the Shared Library - -You need the following additional dependencies: - -- Git (to pull code from GitHub) - -- libatlas (for linear algebraic operations) - -- libopencv (for computer vision operations) - -- python pip (to load relevant python packages for our language bindings) - -Install these dependencies using the following commands in any directory: - -```bash - sudo apt-get update - sudo apt-get -y install git build-essential libatlas-base-dev libopencv-dev graphviz python-pip - sudo pip install pip --upgrade - sudo pip install setuptools numpy --upgrade - sudo pip install graphviz jupyter -``` - -Clone the MXNet source code repository using the following `git` command in your home directory: -```bash - git clone https://github.com/apache/incubator-mxnet.git --recursive - cd incubator-mxnet -``` - -Edit the Makefile to install the MXNet with CUDA bindings to leverage the GPU on the Jetson: -```bash - cp make/crosscompile.jetson.mk config.mk -``` - -Edit the Mshadow Makefile to ensure MXNet builds with Pascal's hardware level low precision acceleration by editing 3rdparty/mshadow/make/mshadow.mk and adding the following after line 122: -```bash -MSHADOW_CFLAGS += -DMSHADOW_USE_PASCAL=1 -``` - -Now you can build the complete MXNet library with the following command: -```bash - make -j $(nproc) -``` - -Executing this command creates a file called `libmxnet.so` in the mxnet/lib directory. - -**Step 2** Install MXNet Python Bindings - -To install Python bindings run the following commands in the MXNet directory: - -```bash - cd python - pip install --upgrade pip - pip install -e . -``` - -Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. - -Add the mxnet folder to the path: - -```bash - cd .. - export MXNET_HOME=$(pwd) - echo "export PYTHONPATH=$MXNET_HOME/python:$PYTHONPATH" >> ~/.bashrc - source ~/.bashrc -``` - -You are now ready to run MXNet on your NVIDIA Jetson TX2 device. - -
-
- - - - - -# Validate MXNet Installation - -
-
-
- -
- -Start the python terminal. - -```bash -$ python -``` -
- -
- -Launch a Docker container with `mxnet/python` image and run example *MXNet* python program on the terminal. - -```bash -$ docker run -it mxnet/python bash # Use sudo if you skip Step 2 in the installation instruction - -# Start a python terminal -root@4919c4f58cac:/# python -``` -
- -
- -Activate the virtualenv environment created for *MXNet*. - -```bash -$ source ~/mxnet/bin/activate -``` - -After activating the environment, you should see the prompt as below. - -```bash -(mxnet)$ -``` - -Start the python terminal. - -```bash -$ python -``` - -
- -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. - -```python ->>> import mxnet as mx ->>> a = mx.nd.ones((2, 3)) ->>> b = a * 2 + 1 ->>> b.asnumpy() -array([[ 3., 3., 3.], - [ 3., 3., 3.]], dtype=float32) -``` -
-
-
- - - -
-
-
-
- -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. - -```python ->>> import mxnet as mx ->>> a = mx.nd.ones((2, 3)) ->>> b = a * 2 + 1 ->>> b.asnumpy() -array([[ 3., 3., 3.], - [ 3., 3., 3.]], dtype=float32) -``` - -
-
-
-
- - - -
-
-
- -
-
- -Will be available soon. - -
- -
-
- -From the MXNet root directory run: `python example/image-classification/train_mnist.py --network lenet --gpus 0` to test GPU training. - -
- -
-
-
- - - -
-
-
- -
-
- -Will be available soon. - -
- -
-
- -From the MXNet root directory run: `python example/image-classification/train_mnist.py --network lenet --gpus 0` to test GPU training. - -
- -
-
-
- - - -
-
-
- -
- -Start the python terminal. - -```bash -$ python -``` -
- -
- -Launch a NVIDIA Docker container with `mxnet/python:gpu` image and run example *MXNet* python program on the terminal. - -```bash -$ nvidia-docker run -it mxnet/python:gpu bash # Use sudo if you skip Step 2 in the installation instruction - -# Start a python terminal -root@4919c4f58cac:/# python -``` -
- -
- -Activate the virtualenv environment created for *MXNet*. - -```bash -$ source ~/mxnet/bin/activate -``` - -After activating the environment, you should see the prompt as below. - -```bash -(mxnet)$ -``` - -Start the python terminal. - -```bash -$ python -``` - -
- -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. - -```python ->>> import mxnet as mx ->>> a = mx.nd.ones((2, 3), mx.gpu()) ->>> b = a * 2 + 1 ->>> b.asnumpy() -array([[ 3., 3., 3.], - [ 3., 3., 3.]], dtype=float32) -``` -
-
-
- - - - - - - -
-
-
- -
- -Exit the Python terminal. - -```python ->>> exit() -$ -``` -
- -
- -Exit the Python terminal and Deactivate the virtualenv *MXNet* environment. -```python ->>> exit() -(mxnet)$ deactivate -$ -``` - -
- -
- -Exit the Python terminal and mxnet/python docker container. -```python ->>> exit() -root@4919c4f58cac:/# exit -``` - -
- -
-
-
- - -
-
-
- -
- -Exit the Python terminal. - -```python ->>> exit() -$ -``` -
- -
- -Exit the Python terminal and Deactivate the virtualenv *MXNet* environment. -```python ->>> exit() -(mxnet)$ deactivate -$ -``` - -
- -
- -Exit the Python terminal and then the docker container. -```python ->>> exit() -root@4919c4f58cac:/# exit -``` - -
- -
-
-
- - - -
- -Login to the cloud instance you launched, with pre-installed *MXNet*, following the guide by corresponding cloud provider. - - -Start the python terminal. - -```bash -$ python -``` - - -
- -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. - -```python ->>> import mxnet as mx ->>> a = mx.nd.ones((2, 3)) ->>> b = a * 2 + 1 ->>> b.asnumpy() -array([[ 3., 3., 3.], - [ 3., 3., 3.]], dtype=float32) - ``` - -Exit the Python terminal. - -```python ->>> exit() -$ -``` - -
- - - -
- -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. - -```python ->>> import mxnet as mx ->>> a = mx.nd.ones((2, 3), mx.gpu()) ->>> b = a * 2 + 1 ->>> b.asnumpy() -array([[ 3., 3., 3.], - [ 3., 3., 3.]], dtype=float32) -``` - -
- -
- - - -
-
-
- -Run a short *MXNet* R 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 -``` - -You should see the following output: - -```r -[,1] [,2] [,3] -[1,] 3 3 3 -[2,] 3 3 3 -``` - -
-
-
- - - -
-
-
- -Run a short *MXNet* R 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 -``` - -You should see the following output: - -```r -[,1] [,2] [,3] -[1,] 3 3 3 -[2,] 3 3 3 -``` - -
-
-
- - - -
-
- -
- Run the MXNet-Scala demo project to validate your Maven package installation. -
- -
- -
-
- -Will be available soon. - -
-
-
- -
-
-
- Run the MXNet-Scala demo project to validate your Maven package installation. -
-
-
-
- -Will be available soon. - -
-
-
- - -
-
-
- -
-
-Will be available soon. -
- -
-
- -
-
- -Will be available soon. - -
-
-
- - -
+
# Source Download -Download your required version of MXNet. +Download your required version of MXNet and build from source. diff --git a/docs/install/osx_setup.md b/docs/install/osx_setup.md index b90dfd1e582c..53039252888d 100644 --- a/docs/install/osx_setup.md +++ b/docs/install/osx_setup.md @@ -102,11 +102,22 @@ If building with ```GPU``` support, add the following configuration to config.mk   We have installed MXNet core library. Next, we will install MXNet interface package for the programming language of your choice: +- [Python](#install-mxnet-for-python) - [R](#install-the-mxnet-package-for-r) - [Julia](#install-the-mxnet-package-for-julia) - [Scala](#install-the-mxnet-package-for-scala) - [Perl](#install-the-mxnet-package-for-perl) +## Install MXNet for Python +To install the MXNet Python binding navigate to the root of the MXNet folder then run the following: + +```bash +$ cd python +$ pip install -e . +``` + +Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. + ## Install the MXNet Package for R You have 2 options: 1. Building MXNet with the Prebuilt Binary Package diff --git a/docs/install/ubuntu_setup.md b/docs/install/ubuntu_setup.md index 13280b58573e..432310dd763d 100644 --- a/docs/install/ubuntu_setup.md +++ b/docs/install/ubuntu_setup.md @@ -115,8 +115,8 @@ You can build MXNet from source, and then you have the option of installing lang ### Build the Shared Library -#### Quick MXNet Installation -You can quickly build MXNet with the following script found in the `/docs/install` folder: +#### Quick MXNet Build +You can quickly build MXNet from source with the following script found in the `/docs/install` folder: ```bash cd docs/install @@ -127,6 +127,8 @@ Or you can go through a manual process described next. #### Manual MXNet Installation +It is recommended that you review the general [build from source](build_from_source.html) instructions before continuing. + On Ubuntu versions 16.04 or later, you need the following dependencies: **Step 1:** Install build tools and git. @@ -135,14 +137,18 @@ On Ubuntu versions 16.04 or later, you need the following dependencies: sudo apt-get install -y build-essential git ``` -**Step 2:** Install OpenBLAS. +**Step 2:** Install a Math Library. + +Details on the different math libraries are found in the build from source guide's [Math Library Selection](build_from_source.html#math-library-selection) section. -*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. +For OpenBLAS use: ```bash sudo apt-get install -y libopenblas-dev ``` +For other libraries, visit the [Math Library Selection](build_from_source.html#math-library-selection) section. + **Step 3:** Install OpenCV. *MXNet* uses [OpenCV](http://opencv.org/) for efficient image loading and augmentation operations. @@ -153,7 +159,7 @@ On Ubuntu versions 16.04 or later, you need the following dependencies: **Step 4:** Download MXNet sources and build MXNet core shared library. -If building on CPU: +If building on CPU and using OpenBLAS: ```bash git clone --recursive https://github.com/apache/incubator-mxnet.git @@ -161,7 +167,7 @@ If building on CPU: make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas ``` -If building on GPU (make sure you have installed the [CUDA dependencies first](#cuda-dependencies)): +If building on GPU and you want OpenCV and OpenBLAS (make sure you have installed the [CUDA dependencies first](#cuda-dependencies)): ```bash git clone --recursive https://github.com/apache/incubator-mxnet.git @@ -169,38 +175,119 @@ If building on GPU (make sure you have installed the [CUDA dependencies first](# make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1 ``` -*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`. +*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` and also review common [usage examples](build_from_source.html#usage-examples). -Executing these commands creates a library called ```libmxnet.so```. +Building from source creates a library called ```libmxnet.so``` in the `lib` folder in your MXNet project root. -Next, you may optionally install ```graphviz``` library that is used for visualizing network graphs you build on MXNet. You may also install [Jupyter Notebook](http://jupyter.readthedocs.io/) which is used for running MXNet tutorials and examples. +You may also want to add the MXNet shared library to your `LD_LIBRARY_PATH`: ```bash - sudo apt-get install -y python-pip - sudo pip install graphviz - sudo pip install jupyter +export LD_LIBRARY_PATH=~/incubator-mxnet/lib ``` + +After building the MXNet library, you may install language bindings. +
## Installing Language Packages for MXNet After you have installed the MXNet core library. You may install MXNet interface packages for the programming language of your choice: -- [Scala](#install-the-mxnet-package-for-scala) -- [R](#install-the-mxnet-package-for-r) +- [Python](#install-mxnet-for-python) +- [C++](#install-the-mxnet-package-for-c++) +- [Clojure](#install-the-mxnet-package-for-clojure) - [Julia](#install-the-mxnet-package-for-julia) - [Perl](#install-the-mxnet-package-for-perl) +- [R](#install-the-mxnet-package-for-r) +- [Scala](#install-the-mxnet-package-for-scala) +
-### Install the MXNet Package for Scala +### Install MXNet for Python -To use the MXNet-Scala package, you can acquire the Maven package as a dependency. +To install the MXNet Python binding navigate to the root of the MXNet folder then run the following: -Further information is in the [MXNet-Scala Setup Instructions](scala_setup.html). +```bash +$ cd python +$ pip install -e . +``` -If you use IntelliJ or a similar IDE, you may want to follow the [MXNet-Scala on IntelliJ tutorial](../tutorials/scala/mxnet_scala_on_intellij.html) instead. +Note that the `-e` flag is optional. It is equivalent to `--editable` and means that if you edit the source files, these changes will be reflected in the package installed. + +#### Optional Python Packages + +You may optionally install ```graphviz``` library that is used for visualizing network graphs you build on MXNet. You may also install [Jupyter Notebook](http://jupyter.readthedocs.io/) which is used for running MXNet tutorials and examples. + +```bash +sudo pip install graphviz +sudo pip install jupyter +``` +
+ + +### Install the MXNet Package for C++ + +Refer to the [C++ Package setup guide](c_plus_plus.html). +
+ + +### Install the MXNet Package for Clojure + +Refer to the [Clojure setup guide](https://github.com/apache/incubator-mxnet/tree/master/contrib/clojure-package). +
+ + +### Install the MXNet Package for Julia + +The MXNet package for Julia is hosted in a separate repository, MXNet.jl, which is available on [GitHub](https://github.com/dmlc/MXNet.jl). To use Julia binding it with an existing libmxnet installation, set the ```MXNET_HOME``` environment variable by running the following command: + +```bash + export MXNET_HOME=//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: + +```bash + 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: + +```julia + Pkg.add("MXNet") +``` + +For more details about installing and using MXNet with Julia, see the [MXNet Julia documentation](http://dmlc.ml/MXNet.jl/latest/user-guide/install/). +
+ + +### Install the MXNet Package for Perl + +Before you build MXNet for Perl from source code, you must complete [building the shared library](#build-the-shared-library). After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Perl package: + +```bash + sudo apt-get install libmouse-perl pdl cpanminus swig libgraphviz-perl + cpanm -q -L "${HOME}/perl5" Function::Parameters Hash::Ordered PDL::CCS + + MXNET_HOME=${PWD} + export LD_LIBRARY_PATH=${MXNET_HOME}/lib + export PERL5LIB=${HOME}/perl5/lib/perl5 + + cd ${MXNET_HOME}/perl-package/AI-MXNetCAPI/ + perl Makefile.PL INSTALL_BASE=${HOME}/perl5 + make install + + cd ${MXNET_HOME}/perl-package/AI-NNVMCAPI/ + perl Makefile.PL INSTALL_BASE=${HOME}/perl5 + make install + + cd ${MXNET_HOME}/perl-package/AI-MXNet/ + perl Makefile.PL INSTALL_BASE=${HOME}/perl5 + make install +```
+ ### Install the MXNet Package for R Building *MXNet* from source is a 2 step process. @@ -291,69 +378,19 @@ You should see the following output: [2,] 3 3 3 > quit() ``` -
-### Install the MXNet Package for Julia - -The MXNet package for Julia is hosted in a separate repository, MXNet.jl, which is available on [GitHub](https://github.com/dmlc/MXNet.jl). To use Julia binding it with an existing libmxnet installation, set the ```MXNET_HOME``` environment variable by running the following command: - -```bash - export MXNET_HOME=//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: - -```bash - 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: - -```julia - Pkg.add("MXNet") -``` - -For more details about installing and using MXNet with Julia, see the [MXNet Julia documentation](http://dmlc.ml/MXNet.jl/latest/user-guide/install/). -
- - -## Install the MXNet Package for Scala +### Install the MXNet Package for Scala To use the MXNet-Scala package, you can acquire the Maven package as a dependency. -Further information is in the [MXNet-Scala Setup Instructions](./scala_setup.md). - -If you use IntelliJ or a similar IDE, you may want to follow the [MXNet-Scala on IntelliJ tutorial](../tutorials/scala/mxnet_scala_on_intellij.md) instead. - - -### Install the MXNet Package for Perl - -Before you build MXNet for Perl from source code, you must complete [building the shared library](#build-the-shared-library). After you build the shared library, run the following command from the MXNet source root directory to build the MXNet Perl package: - -```bash - sudo apt-get install libmouse-perl pdl cpanminus swig libgraphviz-perl - cpanm -q -L "${HOME}/perl5" Function::Parameters Hash::Ordered PDL::CCS - - MXNET_HOME=${PWD} - export LD_LIBRARY_PATH=${MXNET_HOME}/lib - export PERL5LIB=${HOME}/perl5/lib/perl5 - - cd ${MXNET_HOME}/perl-package/AI-MXNetCAPI/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install - - cd ${MXNET_HOME}/perl-package/AI-NNVMCAPI/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install +Further information is in the [MXNet-Scala Setup Instructions](scala_setup.html). - cd ${MXNET_HOME}/perl-package/AI-MXNet/ - perl Makefile.PL INSTALL_BASE=${HOME}/perl5 - make install -``` +If you use IntelliJ or a similar IDE, you may want to follow the [MXNet-Scala on IntelliJ tutorial](../tutorials/scala/mxnet_scala_on_intellij.html) instead.
+ ## Contributions You are more than welcome to contribute easy installation scripts for other operating systems and programming languages. See the [community contributions page](../community/contribute.html) for further information. diff --git a/docs/install/validate_mxnet.md b/docs/install/validate_mxnet.md new file mode 100644 index 000000000000..a4cf5446f606 --- /dev/null +++ b/docs/install/validate_mxnet.md @@ -0,0 +1,185 @@ +# Validate Your MXNet Installation + +- [Python](#python) +- [Python with GPU](#python-with-gpu) +- [Verify GPU training](#verify-gpu-training) +- [Virtualenv](#virtualenv) +- [Docker with CPU](#docker-with-cpu) +- [Docker with GPU](#docker-with-gpu) +- [Cloud](#cloud) +- [C++](#alternative-language-bindings) +- [Clojure](#clojure) +- [Julia](#julia) +- [Perl](#perl) +- [R](#r) +- [Scala](#scala) + + +## Python + +Start the python terminal. + +```bash +$ python +``` + +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. + +```python +>>> import mxnet as mx +>>> a = mx.nd.ones((2, 3)) +>>> b = a * 2 + 1 +>>> b.asnumpy() +array([[ 3., 3., 3.], + [ 3., 3., 3.]], dtype=float32) +``` + + +## Python with GPU + +This is similar to the previous example, but this time we use *mx.gpu()*, to set *MXNet* context to be GPUs. + +```python +>>> import mxnet as mx +>>> a = mx.nd.ones((2, 3), mx.gpu()) +>>> b = a * 2 + 1 +>>> b.asnumpy() +array([[ 3., 3., 3.], + [ 3., 3., 3.]], dtype=float32) +``` + + +## Verify GPU Training + +From the MXNet root directory run: `python example/image-classification/train_mnist.py --network lenet --gpus 0` to test GPU training. + + +## Virtualenv + +Activate the virtualenv environment created for *MXNet*. + +```bash +$ source ~/mxnet/bin/activate +``` + +After activating the environment, you should see the prompt as below. + +```bash +(mxnet)$ +``` + +Start the python terminal. + +```bash +$ python +``` + +Run the previous Python example. + + +## Docker with CPU + +Launch a Docker container with `mxnet/python` image and run example *MXNet* python program on the terminal. + +```bash +$ docker run -it mxnet/python bash # Use sudo if you skip Step 2 in the installation instruction + +# Start a python terminal +root@4919c4f58cac:/# python +``` + +Run the previous Python example. + + +## Docker with GPU + +Launch a NVIDIA Docker container with `mxnet/python:gpu` image and run example *MXNet* python program on the terminal. + +```bash +$ nvidia-docker run -it mxnet/python:gpu bash # Use sudo if you skip Step 2 in the installation instruction + +# Start a python terminal +root@4919c4f58cac:/# python +``` + +Run the previous Python example and run the previous GPU examples. + + +## Cloud + +Login to the cloud instance you launched, with pre-installed *MXNet*, following the guide by corresponding cloud provider. + +Start the python terminal. + +```bash +$ python +``` + +Run the previous Python example, and for GPU instances run the previous GPU example. + + +## Alternative Language Bindings + +### C++ + +Please contribute an example! + + +### Clojure + +Please contribute an example! + + +### Julia + +Please contribute an example! + + +### Perl + +Please contribute an example! + + +### R + +Run a short *MXNet* R 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 +``` + +You should see the following output: + +```r +[,1] [,2] [,3] +[1,] 3 3 3 +[2,] 3 3 3 +``` + + +#### R with GPU + +This is similar to the previous example, but this time 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 +``` + +You should see the following output: + +```r +[,1] [,2] [,3] +[1,] 3 3 3 +[2,] 3 3 3 +``` + + +### Scala + +Run the MXNet-Scala demo project to validate your Maven package installation. diff --git a/docs/install/windows_setup.md b/docs/install/windows_setup.md index 40ddeb8182d8..99ce7f63e850 100755 --- a/docs/install/windows_setup.md +++ b/docs/install/windows_setup.md @@ -91,7 +91,7 @@ Done! We have installed MXNet with Python interface. Run below commands to verif ``` We actually did a small tensor computation using MXNet! You are all set with MXNet on your Windows machine. -## Install MXNet Package for R +## Install the MXNet Package for R MXNet for R is available for both CPUs and GPUs. ### Installing MXNet on a Computer with a CPU Processor @@ -151,8 +151,8 @@ These dlls can be found in `prebuildbase_win10_x64_vc14/3rdparty`, `mxnet_x64_vc ├── dmlc ├── mxnet ├── mshadow - └── nnvm - + └── nnvm + ``` 6. Make sure that R executable is added to your ```PATH``` in the environment variables. Running the ```where R``` command at the command prompt should return the location. 7. Also make sure that Rtools is installed and the executable is added to your ```PATH``` in the environment variables. @@ -200,7 +200,7 @@ To install MXNet on a computer with a GPU processor, choose from two options: * Build the library from source code However, a few dependencies remain for both options. You will need the following: -* Install [Nvidia-drivers](http://www.nvidia.com/Download/index.aspx?lang=en-us) if not installed. Latest driver based on your system configuration is recommended. +* Install [Nvidia-drivers](http://www.nvidia.com/Download/index.aspx?lang=en-us) if not installed. Latest driver based on your system configuration is recommended. * Install [Microsoft Visual Studio](https://visualstudio.microsoft.com/downloads/) (VS2015 or VS2017 is required by CUDA) @@ -224,7 +224,7 @@ For GPU package: ``` Change cu92 to cu80, cu90 or cu91 based on your CUDA toolkit version. Currently, MXNet supports these versions of CUDA. #### Building MXNet from Source Code(GPU) -After you have installed above software, continue with the following steps to build MXNet-R: +After you have installed above software, continue with the following steps to build MXNet-R: 1. Clone the MXNet github repo. ```sh @@ -261,8 +261,8 @@ These dlls can be found in `prebuildbase_win10_x64_vc14/3rdparty`, `mxnet_x64_vc ├── dmlc ├── mxnet ├── mshadow - └── nnvm - + └── nnvm + ``` 6. Make sure that R executable is added to your ```PATH``` in the environment variables. Running the ```where R``` command at the command prompt should return the location. 7. Also make sure that Rtools is installed and the executable is added to your ```PATH``` in the environment variables.