Installing MXNet

Indicate your preferred configuration. Then, follow the customized commands to install MXNet.


$ pip install mxnet
$ pip install mxnet==1.2.1
$ pip install mxnet==1.1.0
$ pip install mxnet==1.0.0
$ pip install mxnet==0.12.1

For MXNet 0.12.0:

$ pip install mxnet==0.12.0
$ pip install mxnet==0.11.0
$ pip install mxnet --pre

MXNet offers MKL pip packages 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

NOTES:

mxnet-cu92mkl means the package is built with CUDA/cuDNN and MKL-DNN enabled and the CUDA version is 9.2.

All MKL pip packages are experimental prior to version 1.3.0.


Docker images with MXNet are available at Docker Hub.

Step 1 Install Docker on your machine by following the docker installation instructions.

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 to allow managing docker containers without sudo.

If you skip this step, you need to use sudo each time you invoke Docker.

Step 3 Pull the MXNet docker image.

$ docker pull mxnet/python # Use sudo if you skip Step 2

You can list docker images to see if mxnet/python docker image pull was successful.

$ 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

Using the latest MXNet with Intel MKL-DNN is recommended for the fastest inference speeds with MXNet.

$ docker pull mxnet/python:1.3.0_cpu_mkl # Use sudo if you skip Step 2
$ docker images # Use sudo if you skip Step 2

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        1.3.0_cpu_mkl       deaf9bf61d29        4 days ago          678 MB

Step 4 Validate the installation.


To build from source, refer to the MXNet Ubuntu installation guide.

$ pip install mxnet-cu92
$ pip install mxnet-cu92==1.2.1
$ pip install mxnet-cu91==1.1.0
$ pip install mxnet-cu90==1.0.0
$ pip install mxnet-cu90==0.12.1
$ pip install mxnet-cu80==0.11.0
$ pip install mxnet-cu92 --pre

MXNet offers MKL pip packages 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

NOTES:

mxnet-cu92mkl means the package is built with CUDA/cuDNN and MKL-DNN enabled and the CUDA version is 9.2.

All MKL pip packages are experimental prior to version 1.3.0.

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:

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.

Step 1 Install Docker on your machine by following the docker installation instructions.

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 to allow managing docker containers without sudo.

If you skip this step, you need to use sudo each time you invoke Docker.

Step 3 Install nvidia-docker-plugin following the installation instructions. nvidia-docker-plugin is required to enable the usage of GPUs from the docker containers.

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.

$ 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

Using the latest MXNet with Intel MKL-DNN is recommended for the fastest inference speeds with MXNet.

$ docker pull mxnet/python:1.3.0_cpu_mkl # Use sudo if you skip Step 2
$ docker images # Use sudo if you skip Step 2

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        1.3.0_gpu_cu92_mkl  adcb3ab19f50        4 days ago          4.23 GB

Step 5 Validate the 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.

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:

$ cd incubator-mxnet
$ make rpkg

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.

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:

$ cd incubator-mxnet
$ make rpkg

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

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-linux-x86_64-gpu</artifactId>
</dependency>



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

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-linux-x86_64-cpu</artifactId>
</dependency>



You can use the Maven packages defined in the following dependency to include MXNet in your Clojure project. To maximize leverage, the Clojure package has been built on the existing Scala package. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process that is required to use the Clojure dependency.

maven badge

<dependency>
    <groupId>org.apache.mxnet.contrib.clojure</groupId>
    <artifactId>clojure-mxnet-linux-gpu</artifactId>
</dependency>



You can use the Maven packages defined in the following dependency to include MXNet in your Clojure project. To maximize leverage, the Clojure package has been built on the existing Scala package. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process that is required to use the Clojure dependency.

maven badge

<dependency>
    <groupId>org.apache.mxnet.contrib.clojure</groupId>
    <artifactId>clojure-mxnet-linux-cpu</artifactId>
</dependency>



You can use the Maven packages defined in the following dependency to include MXNet in your Java project. The Java API is provided as a subset of the Scala API and is intended for inference only. Please refer to the MXNet-Java setup guide for a detailed set of instructions to help you with the setup process.

maven badge

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-linux-x86_64-gpu</artifactId>
    <scope>system</scope>
    <version>1.3.1</version>
    <systemPath>/system/path/to/jar/mxnet-full_2.11-linux-x86_64-gpu-1.3.1-SNAPSHOT.jar</systemPath>
</dependency>



You can use the Maven packages defined in the following dependency to include MXNet in your Java project. The Java API is provided as a subset of the Scala API and is intended for inference only. Please refer to the MXNet-Java setup guide for a detailed set of instructions to help you with the setup process.

maven badge

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-linux-x86_64-cpu</artifactId>
    <scope>system</scope>
    <version>1.3.1</version>
    <systemPath>/system/path/to/jar/mxnet-full_2.11-linux-x86_64-cpu-1.3.1-SNAPSHOT.jar</systemPath>
</dependency>



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



$ pip install mxnet
$ pip install mxnet==1.2.1
$ pip install mxnet==1.1.0
$ pip install mxnet==1.0.0
$ pip install mxnet=0.12.1
$ pip install mxnet==0.11.0
$ pip install mxnet --pre

MXNet offers MKL pip packages 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

NOTES:

mxnet-cu92mkl means the package is built with CUDA/cuDNN and MKL-DNN enabled and the CUDA version is 9.2.

All MKL pip packages are experimental prior to version 1.3.0.


Docker images with MXNet are available at Docker Hub.

Step 1 Install Docker on your machine by following the docker installation instructions.

Note - You can install Community Edition (CE) to get started with MXNet.

Step 2 Pull the MXNet docker image.

$ docker pull mxnet/python

You can list docker images to see if mxnet/python docker image pull was successful.

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        latest              00d026968b3c        3 weeks ago         1.41 GB

Using the latest MXNet with Intel MKL-DNN is recommended for the fastest inference speeds with MXNet.

$ docker pull mxnet/python:1.3.0_cpu_mkl # Use sudo if you skip Step 2
$ docker images # Use sudo if you skip Step 2

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        1.3.0_cpu_mkl       deaf9bf61d29        4 days ago          678 MB

Step 4 Validate the installation.


To build from source, refer to the MXNet macOS installation guide.

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.


To run MXNet you also should have OpenCV and OpenBLAS installed. You may install them with brew as follows:

brew install opencv
brew install openblas@0.3.1

Add a soft link to the OpenBLAS installation. This example links the 0.3.1 version:

ln -sf /usr/local/opt/openblas/lib/libopenblasp-r0.3.* /usr/local/opt/openblas/lib/libopenblasp-r0.3.1.dylib

Install the latest version (3.5.1+) of R from CRAN. You can build MXNet-R from source, or you can use a pre-built binary:

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

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
</dependency>


Not available at this time.


You can use the Maven packages defined in the following dependency to include MXNet in your Clojure project. To maximize leverage, the Clojure package has been built on the existing Scala package. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process that is required to use the Clojure dependency.

maven badge

<dependency>
    <groupId>org.apache.mxnet.contrib.clojure</groupId>
    <artifactId>clojure-mxnet-osx-cpu</artifactId>
</dependency>


Not available at this time.

You can use the Maven packages defined in the following dependency to include MXNet in your Java project. The Java API is provided as a subset of the Scala API and is intended for inference only. Please refer to the MXNet-Java setup guide for a detailed set of instructions to help you with the setup process.

maven badge

<dependency>
    <groupId>org.apache.mxnet</groupId>
    <artifactId>mxnet-full_2.11-osx-x86_64-cpu</artifactId>
    <scope>system</scope>
    <version>1.3.1</version>
    <systemPath>/system/path/to/jar/mxnet-full_2.11-osx-x86_64-cpu-1.3.1-SNAPSHOT.jar</systemPath>
</dependency>


Not available at this time.


You can use the Maven packages defined in the following `dependency` to include MXNet in your Clojure project. To maximize leverage, the Clojure package has been built on the existing Scala package. Please refer to the MXNet-Scala setup guide for a detailed set of instructions to help you with the setup process that is required to use the Clojure dependency.

maven badge

<dependency>
    <groupId>org.apache.mxnet.contrib.clojure</groupId>
    <artifactId>clojure-mxnet-osx-cpu</artifactId>
</dependency>


Not available at this time.


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.
$ pip install mxnet
$ pip install mxnet==1.2.1
$ pip install mxnet==1.1.0
$ pip install mxnet==1.0.0
$ pip install mxnet==0.12.1
$ pip install mxnet==0.11.0
$ pip install mxnet --pre

MXNet offers MKL pip packages 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

NOTES:

mxnet-cu92mkl means the package is built with CUDA/cuDNN and MKL-DNN enabled and the CUDA version is 9.2.

All MKL pip packages are experimental prior to version 1.3.0.


Docker images with MXNet are available at Docker Hub.

Step 1 Install Docker on your machine by following the docker installation instructions.

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 to allow managing docker containers without sudo.

If you skip this step, you need to use sudo each time you invoke Docker.

Step 3 Pull the MXNet docker image.

$ docker pull mxnet/python # Use sudo if you skip Step 2

You can list docker images to see if mxnet/python docker image pull was successful.

$ 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

Using the latest MXNet with Intel MKL-DNN is recommended for the fastest inference speeds with MXNet.

$ docker pull mxnet/python:1.3.0_cpu_mkl # Use sudo if you skip Step 2
$ docker images # Use sudo if you skip Step 2

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mxnet/python        1.3.0_cpu_mkl       deaf9bf61d29        4 days ago          678 MB

Step 4 Validate the installation.

$ pip install mxnet-cu92
$ pip install mxnet-cu92==1.2.1
$ pip install mxnet-cu91==1.1.0
$ pip install mxnet-cu90==1.0.0
$ pip install mxnet-cu90==0.12.1
$ pip install mxnet-cu80==0.11.0
$ pip install mxnet-cu92 --pre

MXNet offers MKL pip packages 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

NOTES:

mxnet-cu92mkl means the package is built with CUDA/cuDNN and MKL-DNN enabled and the CUDA version is 9.2.

All MKL pip packages are experimental prior to version 1.3.0.

Anaconda is recommended.

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:

nvcc --version

Refer to #8671 for status on CUDA 9.1 support.

You can either upgrade your CUDA install or install the MXNet package that supports your CUDA version.


To build from source, refer to the MXNet Windows installation guide.


Install the latest version (3.5.1+) of R from CRAN. You can build MXNet-R from source, or you can use a pre-built binary:

cran <- getOption("repos")
cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/"
options(repos = cran)
install.packages("mxnet")

To run MXNet you also should have OpenCV and OpenBLAS installed.


You can build MXNet-R from source, or you can use a pre-built binary:

  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.

MXNet-Clojure for Windows is not yet available.

MXNet-Java for Windows is not yet available.

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 Windows installation 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.

You can also run distributed deep learning with MXNet on AWS using Cloudformation Template.

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.

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 to allow managing docker containers without sudo.

Build

Please use a Native build with gcc 4 as explained below, higher compiler versions currently cause test failures on ARM

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.

ci/build.py -p armv7

Install

Create a virtualenv and install the package we created previously.

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:

Install these dependencies using the following commands in any directory:

    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:

    git clone https://github.com/apache/incubator-mxnet.git --recursive
    cd incubator-mxnet

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)

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:

  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:

    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:

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.

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 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:

    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

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

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

To install Python bindings run the following commands in the MXNet directory:

    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:

    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.


Source Download

Download your required version of MXNet and build from source.