MATLAB Deep Learning Container on NVIDIA GPU Cloud for NVIDIA DGX
Note
Starting from MATLAB® release 2024b, MATLAB Deep Learning Container is no longer supported on NVIDIA® Container Registry. Use the MATLAB Deep Learning Container on Docker Hub instead.
Speed up your deep learning applications by training neural networks in the MATLAB Deep Learning Container, designed to take full advantage of high-performance NVIDIA GPUs. You can access the MATLAB Deep Learning Container remotely using a web browser or via a VNC connection.
The MATLAB Deep Learning Container image contains MATLAB and a range of MATLAB toolboxes that are ideal for deep learning (see Additional Information).
This guide helps you run the MATLAB desktop in the cloud on NVIDIA DGX platforms. The MATLAB Deep Learning Container image, a Docker® container image hosted on NVIDIA GPU Cloud, simplifies the process. The container image is available at the NVIDIA GPU Cloud Container Catalog.
Requirements
To use the MATLAB Deep Learning Container image, you need:
Host DGX system with Docker and NVIDIA Docker installed. For more information on how to configure your DGX system, see Prepare DGX System.
A MATLAB license that meets the following conditions:
Valid for all the MathWorks® products installed in the container. You can obtain a trial license for products in the MATLAB Deep Learning Container at MATLAB Trial for Deep Learning on the Cloud.
Linked to a MathWorks Account.
Configured for cloud use. Individual and Campus-Wide licenses are already configured. For other license types, contact your license administrator. You can identify your license type and administrator by viewing your MathWorks Account. Administrators can consult Administer Network Licenses.
If you have a Concurrent license type, you must supply the port number and DNS address of the network license manager when you run the container. Add an option of the following form to the
docker run
command when you start the container:-e MLM_LICENSE_FILE=27000@MyLicenseServer
Pull Container Image
Pulling the container image downloads the container image onto the Docker host, the machine that runs the container. You have to pull the container image only once.
You can copy the pull command for the container image release from the NVIDIA GPU Cloud Container Catalog. In the Tags section, locate the
container image release that you want to run. In the Pull column, click the icon to copy the
docker pull
command. The command is of the form:
docker pull nvcr.io/partners/matlab:r20XYz
r20XYz
must be replaced with the specific MATLAB release name, for example r2020a
. Ensure the last part of
the pull
command matches the MATLAB release you want to use. Connect to the Docker host via SSH from your client machine using PuTTY or another SSH client. Paste
the docker pull
command into your SSH client, and run the command on the
Docker host. You do not need to log in to the NVIDIA Container Catalog to pull the container image.
Running the docker pull
command downloads the MATLAB container image onto the host machine. It might take some time to download and
extract the large container image.
Run Container
Run the MATLAB Deep Learning Container using this command:
nvidia-docker run -it --rm -p 5901:5901 -p 6080:6080 --shm-size=512M nvcr.io/partners/matlab:r20XYz
Ensure the last part of the run
command matches the MATLAB release you want to use.
The options -p hostport:containerport
map ports from inside the
container to ports on the Docker host so that you can connect to the container desktop. Ports used in the
container are 5901
(for VNC connection) and 6080
(for
web browser connection). If you are deploying multiple containers on the same host machine,
you must increment the host ports until you find a free port. For example:
-p 5902:5901 -p 6081:6080
The MATLAB Deep Learning Container is now running on your DGX machine.
Run MATLAB from the Container
There are three ways to access MATLAB in the container:
Use a web browser to connect to the container desktop and run MATLAB desktop
Use VNC to connect to the container desktop and run MATLAB desktop
Run MATLAB using the command-line interface
If your host machine is protected by a firewall or you cannot access the container desktop via a web browser or VNC, you can set up SSH tunnels to the container (see Create Encrypted Connection to Remote Applications and Containers).
Connect using a Web Browser
Connecting with a web browser uses port 6080
in the container. To
connect, use the URL:
http://hostname:6080
hostname
is the name of the Docker host machine running the container, for example
MyCompanyDGX1
.
You will see a login screen for noVNC. Click connect. When you are prompted for a password to access the desktop, use the password:
matlab
You can run MATLAB using the desktop icon. Log in using your MathWorks Account.
If you cannot log in using your MathWorks Account, check that your account is connected to a license that is configured for cloud use. To check, visit License Center.
Connect using VNC
Connecting with VNC uses port 5901
in the container. VNC connects
to the host display for the host port mapped to container port 5901
;
for example, display 1
for host port 5901
.
To connect, use your VNC client to connect to:
hostname:1
hostname
is the name of the Docker host machine running the container, for example
MyCompanyDGX1
.
To log in and connect to the container desktop, use the password:
matlab
You can run MATLAB using the desktop icon. Log in using your MathWorks Account.
If you cannot log in using your MathWorks Account, check that your account is connected to a license that is configured for cloud use. To check, visit License Center.
Run MATLAB Using the Command-Line Interface
You can run MATLAB from the terminal using the command-line interface using the command:
matlab
Note that there is no graphical desktop in this case.
If you cannot log in using your MathWorks Account, check that your account is connected to a license that is configured for cloud use. To check, visit License Center.
Test Container Using Deep Learning Example
MATLAB supports training a single network in parallel using multiple GPUs. To enable
multi-GPU training in the MATLAB Deep Learning Container, use the trainingOptions
function
to set 'ExecutionEnvironment'
to 'multi-gpu'
.
Train your network using the trainnet
function. MATLAB opens a parallel pool of workers on all available GPUs. To select only
specific GPUs for training, you can use gpuDevice
. For further
information, see Select Particular GPUs to Use for Training (Deep Learning Toolbox).
To test your container, you can run the Create Simple Deep Learning Neural Network for Classification (Deep Learning Toolbox)
example. To try this example, double-click the file MNISTExample.mlx
in
the Current Folder pane in the MATLAB startup folder. To run this example on all available GPUs, in the
trainingOptions
function, set the
'ExecutionEnvironment'
to 'multi-gpu'
.
Close Container Session
To close the container session, type exit
from the container
terminal. The Docker container is stopped and removed. No processes or data are saved by default
when the container is closed, unless you have saved data in the host by mounting host
storage, as described in Share Data with Containers.
Additional Information
How do I Configure the MATLAB Deep Learning Container?
You can configure and customize the behavior of a MathWorks container by setting specific environment variables. For more information, see Configure Containers.
What is NVIDIA GPU Cloud?
NVIDIA GPU Cloud is a Docker repository of container images that are designed to run applications on high-performance NVIDIA GPUs.
What is in the MATLAB Deep Learning Container?
The MATLAB Deep Learning Container contains MATLAB and several other toolboxes that are useful in deep learning applications.
Computer Vision Toolbox™
GPU Coder™
Image Processing Toolbox™
MATLAB Coder™
Deep Learning Toolbox™
Parallel Computing Toolbox™
Signal Processing Toolbox™
Statistics and Machine Learning Toolbox™
Text Analytics Toolbox™
To perform deep learning using GPUs in the MATLAB Deep Learning Container, you must have a license valid for MATLAB, Deep Learning Toolbox, and Parallel Computing Toolbox. A license valid for the other products in the container are required to access the full functionality of the container.
If you do not have a license valid for Deep Learning Toolbox or Parallel Computing Toolbox, MATLAB displays a warning on startup indicating that you cannot use these products.
If you do not have a license valid for other products in the MATLAB Deep Learning Container, MATLAB displays a message on startup indicating that you cannot use these products.
You can obtain a trial license for products in the MATLAB Deep Learning Container at MATLAB Trial for Deep Learning on the Cloud.
In addition, the container contains several Pretrained Deep Neural Networks (Deep Learning Toolbox).
You can import networks and network architectures into the container from TensorFlow™-Keras and Caffe, with or without layer weights. You can also convert trained networks to the Open Neural Network Exchange (ONNX) model format.
Import and Export Neural Networks (Deep Learning Toolbox)
The MATLAB Deep Learning Container also contains:
By deploying this software in a container, you can avoid the set-up time needed to install and configure these products. You can run multiple containers to train several networks at once or in different locations with reproducible results.
Related Topics
- Create Simple Deep Learning Neural Network for Classification (Deep Learning Toolbox)
- Classify Image Using GoogLeNet (Deep Learning Toolbox)
- Get Started with Transfer Learning (Deep Learning Toolbox)