Getting Started
Supported Releases of MATLAB and MATLAB Compiler Runtime
MATLAB Release (Patch level) | MATLAB Compiler Runtime | ||
---|---|---|---|
R2025a | > module load matlab/R2025a | > module load matlab-mcr/R2025a | R2025a |
R2024b | > module load matlab/R2024b_Update3 | > module load matlab-mcr/R2024b_Update3 | R2024b (Update 3) |
Availability | Linux Cluster (CoolMUC-4) | Linux Cluster (CoolMUC-4) |
> module avail matlab
Useful MATLAB Command-line Options
Run MATLAB via the "matlab" command only or add command-line arguments. Please consider: All MATLAB command-line arguments are case-sensitive!
> matlab arg_1 ... arg_N
Command-line argument | Meaning |
---|---|
no argument | Start MATLAB GUI. |
-nodesktop | Start MATLAB without desktop but allow GUI and graphics output (figures). |
-nodisplay | Start MATLAB without any GUI support. Graphics output (figures) is also not possible. |
-singleCompThread | Many intrinsic MATLAB functions automatically exploit multithreading. MATLAB can be forced to disable this feature. Use this option for any work on the login nodes! |
-r myfunc | Run a MATLAB script or function, e. g. myfunc.m. |
Further information:
- https://de.mathworks.com/help/matlab/matlab_env/startup-options.html
- https://de.mathworks.com/help/matlab/matlab_env/commonly-used-startup-options.html
Interactive MATLAB Jobs
LRZ policies for using MATLAB on Login Nodes
MATLAB is a very resource-hungry application with respect to both memory and CPU resources! Please run MATLAB on login nodes with care! Especially, involving multiple threads (many built-in MATLAB functions/operators use multithreading by default) or multiple processes may cause a high load on the login node, may affect the work of other users or have a negative impact on the general operation of the login nodes!
Those MATLAB applications will be terminated by system administrators! Repeated violation of the restrictions on login nodes might result in a ban of the affected user account and notification to the responsible master user or PI.
In addition to the Policies on the Linux Cluster, please also consider the rules when using MATLAB on the login nodes:
- Only run a maximum of one MATLAB instance per login node!
- Disable any kind of parallelization, i.e. multithreading (see command-line options above) or the Parallel Computing Toolbox!
- Check the load and memory consumption of your own MATLAB session. Usually, you can do this via the "top" command, e.g.:
top -u $USER
Recommendations:
We recommend NOT to use the graphical user interface (GUI) of MATLAB, as this unnecessarily increases the load (resource consumption). Furthermore, using GUI decreases the overall performance of MATLAB.
- If the MATLAB GUI is needed, then the CoolMUC Web Portal could be your choice!
- If the MATLAB GUI is not needed, it is better to run MATLAB via an interactive Slurm job (see next section). This job runs on a compute node. Parallelization is explicitly allowed here!
Typical Usecases
(A) I want to run pure MATLAB computations without any need of the MATLAB GUI or visualization
Interactive MATLAB sessions can be started on compute nodes of CoolMUC-4 by employing interactive Slurm jobs. Please refer to Running interactive jobs on the Linux Cluster. We recommend to start MATLAB via
> matlab -nodisplay
(B) I want to run MATLAB computations without the need of the GUI, but visualization is required
Interactive MATLAB sessions can be started on compute nodes of CoolMUC-4 by employing interactive Slurm jobs. Please refer to Running interactive jobs on the Linux Cluster. We recommend to start MATLAB via
> matlab -nodesktop
As GUIs/windows cannot be opened, the graphics output must be written directly to (image) files (as usually done in batch jobs). Therefore, open MATLAB figures without GUI, e.g.:
>> fig = figure('visible', 'off');
(C) I need the MATLAB GUI, or at least figure windows
We recommend to use the CoolMUC Web Portal. This is a web-based access to the Linux Cluster allowing GUI-based MATLAB jobs on the compute nodes of CoolMUC-4. Do the following steps:
- Login to https://ood.hpc.lrz.de using the same credentials you are using on CoolMUC-4.
- Select MATLAB from the dashboard.
- Now, you can setup the Slurm job specifications of your MATLAB job. Recommended settings:
- Select the appropriate partition. That depends on your usecase. Consider the partition limits.
- 1 CPU node, as MATLAB usually cannot use more.
- CPU flavor: Number of cores depends on the usecase. Multi-threading used? Parallel Computing Toolbox used?
- RAM flavor: at least 16 GB. as MATLAB already needs a few GBs after startup.
- Total run time in hours: depends on usecase. Consider the partition limits.
- Launch the job. You may need to wait, as you are starting a Slurm job, waiting for available resources.
- A VNC session will open, automatically starting the MATLAB GUI. Please be patient. The MATLAB startup is quite slow. This is not a problem of the web portal access.
General Considerations
- Interactive jobs depend on the availability of compute resources. Matlab may not start immediately.
- An interactive Matlab session should be limited to 1 compute node only.
- Consider the restrictions on interactive jobs: Job Processing on the Linux-Cluster
Common Batch Jobs
Batch jobs are used for all MATLAB production runs. Usually, the resources, consumed by MATLAB applications, are limited to a single CPU core (pure serial job) or a single compute node (parallel job involving either multithreading or the Parallel Computing Toolbox [PCT]). Following table lists job examples for various cases which can be used on CoolMUC-4.
Slurm job script | Matlab script | Comment |
---|---|---|
Serial batch job | ||
matmul_serial.slurm | matmul_serial.m | No parallelization at all, MATLAB is intended to run on a single core. |
Parallel job using multithreading | ||
matmul_mthread.slurm | matmul_mthread.m | MATLAB will run on a single compute node. |
Parallel batch job using Parallel Computing Toolbox (PCT) | ||
matmul_pct.slurm | matmul_pct.m | MATLAB will run on a single compute node. |