Validate Your MXNet Installation¶
Python¶
Start the python terminal.
$ 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.
>>> 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 MKL¶
Instructions for validating MKL or MKLDNN can be found in the MKLDNN_README.
Python with GPU¶
This is similar to the previous example, but this time we use `mx.gpu()``, to set MXNet’s context to be GPU.
>>> 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¶
Clone the MXNet repository to download all of the MXNet examples.
git clone --recursive https://github.com/apache/incubator-mxnet.git mxnet
From the mxnet
directory run the following:
python example/image-classification/train_mnist.py --network lenet --gpus 0