Skip to main content

NVIDIA GPU Cloud (NGC) has partnered with MathWorks to provide Matlab in Docker image.  Once you have access to NGC, you will be able to run Matlab from DGX cluster master node interactively.  In the following note, we demonstrate how to invoke Matlab by pulling the Matlab Docker image from NGC and getting a Matlab license from ITS Research Computing Matlab license server.

First, login to DGX cluster master node with X11 forwarding enable.

ssh -X dgx.its.unc.edu

At the DGX cluster master node prompt, run the following command.

nvidia-docker run -it --rm -p 5901:5901 -p 6080:6080 --shm-size=512M -e MLM_LICENSE_FILE=1712@license0.its.unc.edu nvcr.io/partners/matlab:r2018a

The options -p hostport:containerport map ports from inside the container to ports on the DGX master node 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 we are running multiple containers by one person or many people, we must increment the host ports until we find a free port.  For example:

-p 5902:5901 -p 6081:6080

The options -e MLM_LICENSE_FILE=1712@license0.its.unc.edu is to tell where to access license server to get Matlab license.  You will have to be on campus network or off campus via VPN to be able to check out Matlab license from our license server.

The options –shm-size=512M is used to set the size of shared memory to 512MB.

We are running Matlab version r2018a.  As of October 2018, Matlab version r2018b is also available.  However, that new version requires CUDA 9.2 to run.  DGX is running CUDA 9.0.

Once we have Matlab Docker container running, we can connect to it easily using the command line interface.  Open up a terminal and run the following command.

matlab

Note that there is no graphical desktop in this case.

In order to have access to Matlab graphical desktop, we can use a web browser such as Firefox running on the DGX cluster master node.  At the DGX prompt, run the following command.

firefox http://localhost:6080

If we increment the host port in the nvidia-docker run command, use the appropriate host port number, for example 6081.

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 then run Matlab using the desktop icon.