From HPC users
Revision as of 11:58, 23 September 2022 by Schwietzer (talk | contribs) (→‎Introduction)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search


MATLAB is a commercial software product of Mathworks Inc. for solving mathematical and scientific problems and for displaying results graphically. MATLAB is primarily designed for numerical calculations with matrices, the name was derived from that purpose: MATrix LABoratory.

== Installed version(s)

These versions are installed and and currently available on all environments ...


MATLAB at the University Oldenburg

A campus license agreement provides access to MATLAB, Simulink and a variety of toolboxes for all students, scientists, and employees at the University Oldenburg. The licensed software products may be installed on computers in the campus network and on laptops and computers at home. While the license agreement is running the software can be used for as long as you are a member of the University (as student or employee). The software can be used for teaching and research only, commercial applications are explicitly prohibited by the license agreement.

If you want to use MATLAB you can find instructions on downloading and installing the software at the web pages of IT services (German only). You may need to contact your local system administrator for help. It is recommended to install a recent version of MATLAB to get the most features and also optimal performance.

Using MATLAB with the HPC cluster

On the HPC clusters MATLAB is installed, the command

module spider matlab

will show you which versions are available. To run MATLAB you need to load the module and the corresponding environment for the desired version, e.g.

module load hpc-env/6.4
module load MATLAB/2018b

(note that unlike the spider command, the load command is case-sensitive). After that you can start MATLAB with



matlab -nodisplay

if you have not enabled X-forwarding at login.

Please note that MATLAB should not be used on the login nodes for compute-intensive applications. In that case you should submit a MATLAB job to the cluster which is then executed on the compute nodes. There are three ways of running MATLAB on a compute node:

  1. Use MATLAB Distributed Compute Server (MDCS) to submit MATLAB jobs from your desktop computer to the cluster. This is the recommended way, and is explained in detail in this Wiki (see below).
  2. Write a SLURM batch job script that calls MATLAB and runs a pre-defined MATLAB program. You can use a complete compute node for this if you allocate the resources accordingly. Explanations may follow in the future.
  3. Run MATLAB interactively on a compute node using srun:
srun --ntasks=1 --cpus-per-task=24 -p carl.p matlab

MATLAB only runs in text-based mode this way (even without the -nodisplay option). The interactive session will automatically terminate after 2 hours (the default time limit). You can use additional srun-options to request more resources, e.g. --time=hh:mm:ss for a different time limit.

IMPORTANT NOTE: Make sure you are not using more compute cores than allocated when using options 2. or 3. above. Per default MATLAB should automatically detect the number of available compute cores and should make use of all of them. Since compute nodes are a shared resource, trying to use more than the allocated resources may interfere with other jobs! To avoid this problem you can:

  1. allocate a compute node exclusively (see SLURM examples on how to achieve this, the srun-example above does it by allocating all cores)
  2. limit the number of compute threads in MATLAB by adding the line

to your MATLAB code. N is the number of compute threads and it must match the --cpus-per-tasks setting of your job allocation.

MATLAB Distributed Compute Server

The MATLAB Distributed Compute Server (MDCS) is a special mechanism that allow users to setup and submit jobs in MATLAB from their own computer (desktop, laptop). The job is then scheduled and executed on the cluster. The results are returned back to your own MATLAB session. This is the recommended procedure for using MATLAB on the HPC cluster and itt requires to configure MATLAB on your local computer once. The configuration of MATLAB is explained in detail on the next page, the steps to take are:

  1. Install MATLAB on your computer (version must be available on the cluster, too).
  2. Configure MATLAB for MDCS on your computer.

Once the setup has been done, you can start submitting jobs to the cluster as explained in MDCS examples page. Further information can be found on the MDCS tutorial pages and on the Mathworks web page.