How to improve interactive performance of MATLAB#

When using ssh X11-Forwarding (options -X or -Y), matlab can be slow to start and also exhibit 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.

A way to eliminate this issue is to use dedicated resources and to start a remote desktop session that does not suffer from network latencies in the same manner. This approach requires a VNC client vncviewer installed on your local machine. A widely used VNC client is TurboVNC.

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 Levante node. The launcher automatically connects to Levante, reserves a 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 user and project accounts or to use the corresponding command line options, for example:

your-machine:~> chmod u+x start-vnc
your-machine:~> ./start-vnc
your-machine:~> ./start-vnc -u <userid> -v /path/to/vncviewer -b '-A <project-id> -p interactive --mem=10G'

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)? n

The created password will be stored in the $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 Levante 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 by clicking the Activities menu and typing terminal in the search field subsequently shown.

Thereafter, you can load the matlab module in the terminal window and start the application:

$ source /etc/profile
$ module load matlab
$ matlab &

On GPU nodes, the program execution can additionally benefit from hardware acceleration for 3D-plots or other graphics-intensive matlab sessions. In this case you need to start matlab with vglrun and without software OpenGL:

$ vglrun matlab

To terminate your VNC session choose the Disconnect icon [x] in the top menu of the VNC desktop.