How to improve interactive performance of MATLAB¶
When using ssh X11-Forwarding (options -X or -Y), matlab can be slow to start and also have slow response to interactive use. This is because X11 sends many small packets over the network, often awaiting a response before continuing. This interacts unfavorably with medium or even higher latency connections, i.e. WiFi. When starting matlab on mistralpp nodes, another disturbing factor is overloading of these nodes.
But mistral has means to eliminate both of these issues: GPU nodes provide exclusive resources and allow for starting a remote desktop session that does not suffer from network latencies. Furthermore, the program execution can benefit from the hardware acceleration for 3D-plots or other graphics-intensive matlab sessions.
The steps to set this up are as follows:
Reserve resources on a GPU node (if you know the number of CPUs or the amount of memory needed for your Matlab session provide the -n or –mem options or use the -N 1 option to reserve a node exclusively) and connect to it via ssh from one of the login nodes:
mlogin100% salloc -n 1 --mem 32000 -p gpu -t 12:00:00 -A YOUR_PROJECT -- /bin/bash -c 'ssh -X $SLURM_JOB_NODELIST'
Start a VNC server on the GPU node:
mgXXX% /opt/TurboVNC/bin/vncserver -geometry 1680x1050 -localhost
The argument of geometry should take a value that works well for your screen, see your desktop preferences for an appropriate value.
The output will be something like
Desktop 'TurboVNC: mg100:1 (k202069)' started on display mg100:1
Notice the server, in this case mg100, and the display (:1).
Open a second ssh connection from your local computer. Here we forward the port for vnc communication which is 5900 + display number. For the example above, it would be 5901.
your-machine:~> ssh mgXXX.dkrz.de -L YYYY:localhost:YYYY
Enter your specific host and port number for XXX and YYYY
Start vncviewer on your local machine:
your-machine:~> vncviewer localhost:DISPLAY
DISPLAY must match what your session in 1. provided.If your local machine has Linux or Mac operating system you can use a launcher provided by DKRZ to easily establish a VNC connection to a GPU node. The launcher automatically connects to Mistral, reserves a GPU node, starts a vnc server and connects to this server using your local vncviewer. You need to complete the downloaded script start-vnc by adding your personal project and user numbers or to use the corresponding command line options:
your-machine:~> chmod u+x start-vnc your-machine:~> ./start-vnc your-machine:~> ./start-vnc -u <userid> -A <prj_account>
To list all available command line options execute:
your-machine:~> ./start-vnc -h
If you have not set a VNC server password yet, the vncpasswd command will be called in the script and you will be prompted to create a password:
No VNC password found. Please set now. ... Password: Verify: Would you like to enter a view-only password (y/n)? nThe created password will be stored in $HOME/.vnc/passwd file. Since it only protects the VNC session, it should be different from your regular access password to DKRZ services. Also, since the password will only be used in automated logins afterwards and you don’t need to enter it on the console, it can be long and random at no cost.Furthermore, public key based login to MISTRAL is recommended to avoid multiple entering of your regular password.
In the VNC desktop that should appear on your local workstation, open a terminal window via the Applications menu:
Applications -> System Tools -> Terminal
Load the matlab module in the terminal window and start matlab with vglrun and without software OpenGL:
$ source /etc/profile.d/mistral.sh $ module load matlab $ vglrun matlabNote: It is necessary to start MATLAB in your HOME directory to avoid excessive warnings or error messages.
To terminate your VNC session choose the Disconnect icon [x] in the top menu of the VNC desktop.