Examples of Running Containers

Logging Into the NGC Container Registry

Skip this section if you provided your API Key when logging into the VM via SSH.

If you did not provide your API Key when connecting to your instance, then you must perform this step.

Log in to the NGC container registry using the following Docker command.

docker login nvcr.io

You will be prompted to enter a Username and Password. Type “$oauthtoken” exactly as shown, and enter your NGC API key obtained during NGC account setup:

Username: $oauthtoken

Password: <Your NGC API Key>

From this point you can run Docker commands and access the NGC container registry from the VM instance.

Example: MNIST Training Run Using PyTorch Container

Once logged in to the Amazon EC2 P3 instance, you can run the MNIST example under PyTorch.

Note that the PyTorch example will download the MNIST dataset from the web.

Pull and run the PyTorch container:

docker pull nvcr.io/nvidia/pytorch:17.10
nvidia-docker run --rm -it nvcr.io/nvidia/pytorch:17.10

Run the MNIST example:

cd /opt/pytorch/examples/mnist
python main.py

Example: MNIST Training Run Using TensorFlow Container

Once logged in to the Amazon EC2 P3 instance, you can run the MNIST example under TensorFlow.

Note that the TensorFlow built-in example will pull the MNIST dataset from the web.

Pull and run the TensorFlow container:

docker pull nvcr.io/nvidia/tensorflow:17.10
nvidia-docker run --rm -it nvcr.io/nvidia/tensorflow:17.10

Following this tutorial: https://www.tensorflow.org/get_started/mnist/beginners

Run the MNIST_with_summaries example:

cd /opt/tensorflow/tensorflow/examples/tutorials/mnist
python mnist_with_summaries.py