You are here: Home / Help / FAQ / Mistral / How to improve interactive performance of MATLAB

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:

  1. 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'
  2. Start a VNC server on the GPU node:

    mgXXX% /opt/TurboVNC/bin/vncserver -geometry 1680x1050

    The argument of geometry should take a value that works well for your screen, see your desktop preferences for an appropriate value.

  3. Start vncviewer on your local machine, e.g.:

    your-machine:~> vncviewer

    Hostname (mgXXX) and DISPLAY must match what your session in 1. provided, i.e. if the output was

    Desktop 'TurboVNC: mg100:1 (k202069)' started on display mg100:1)

    then mgXXX needs to be replaced with mg100 and DISPLAY needs to be replaced with 1.

    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 by adding your personal project and user numbers, as well as the correct path to you local vncviewer installation or to use the corresponding command line options:

    your-machine:~> chmod u+x
    your-machine:~> ./
    your-machine:~> ./ -u <userid> -A <prj_account> -v <path_to_vncviewer>

    To list all available command line options execute:

    your-machine:~> ./ -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.
    Would you like to enter a view-only password (y/n)? n

    The 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.

  4. In the VNC desktop that should appear on your local workstation, open a terminal window via the Applications menu:

    Applications -> System Tools -> Terminal

  5. Load the matlab module in the terminal window and start matlab with vglrun and without software OpenGL:

    $ source /sw/rhel6-x64/etc/profile.mistral
    $ module load matlab $ vglrun matlab -nosoftwareopengl
    Note: It is necessary to start MATLAB in your HOME directory to avoid excessive warnings or error messages.

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

Document Actions