MXNet: A Scalable Deep Learning Framework

MXNet is an open-source deep learning framework that allows you to define, train, and deploy deep neural networks on a wide array of devices, from cloud infrastructure to mobile devices. It is highly scalable, allowing for fast model training, and supports a flexible programming model and multiple languages. MXNet allows you to mix symbolic and imperative programming flavors to maximize both efficiency and productivity. MXNet is built on a dynamic dependency scheduler that automatically parallelizes both symbolic and imperative operations on the fly. A graph optimization layer on top of that makes symbolic execution fast and memory efficient. The MXNet library is portable and lightweight, and it scales to multiple GPUs and multiple machines.

Quick Overview

>>> import mxnet as mx
>>> a = mx.nd.ones((2, 3), mx.gpu())
>>> print ((a * 2).asnumpy())
[[ 2.  2.  2.]
 [ 2.  2.  2.]]
scala> import ml.dmlc.mxnet._
import ml.dmlc.mxnet._

scala> val arr = NDArray.ones(2, 3)
arr: ml.dmlc.mxnet.NDArray = ml.dmlc.mxnet.NDArray@f5e74790

scala> arr.shape
res0: ml.dmlc.mxnet.Shape = (2,3)

scala> (arr * 2).toArray
res2: Array[Float] = Array(2.0, 2.0, 2.0, 2.0, 2.0, 2.0)

scala> (arr * 2).shape
res3: ml.dmlc.mxnet.Shape = (2,3)
> require(mxnet)
Loading required package: mxnet
> a <- mx.nd.ones(c(2,3))
> a
     [,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
> a + 1
     [,1] [,2] [,3]
[1,]    2    2    2
[2,]    2    2    2
julia> using MXNet

julia> a = mx.ones((2,3), mx.gpu())
mx.NDArray{Float32}(2,3)

julia> Array{Float32}(a * 2)
2×3 Array{Float32,2}:
 2.0  2.0  2.0
 2.0  2.0  2.0
pdl> use AI::MXNet qw(mx)
pdl> $a = mx->nd->ones([2, 3], ctx => mx->gpu())
pdl> print (($a * 2)->aspdl)
[
 [2 2 2]
 [2 2 2]
]

Setup MXNet


Installing the pre-build python package requires a recent version of pip, which, for example, can be installed by

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

macOS

Install by:

pip install mxnet

Linux

Use one of following commands to install the desired release:

pip install mxnet       # CPU
pip install mxnet-mkl   # CPU with MKL-DNN acceleration
pip install mxnet-cu75  # GPU with CUDA 7.5
pip install mxnet-cu80  # GPU with CUDA 8.0

The CUDA versions requires both CUDA and cuDNN are installed.

Python

docker pull mxnet/python
docker pull mxnet/python:gpu

Scala

docker pull mxnet/scala

R

docker pull mxnet/r-lang
docker pull mxnet/r-lang:gpu

Julia

docker pull mxnet/julia
docker pull mxnet/julia:gpu

Refer to docker/ for more details.

Refer to setup for details on building MXNet from source codes for various systems.