There are four ways to run Matlab:
- Using the Matlab graphical application through Open OnDemand.
- Graphical mode using the Open OnDemand Desktops.
- The command line version using modules. This is the most common as you will typically submit a job using SLURM.
Like any other application, Matlab has to be loaded as a module before you can use it. To see all the installed versions of the Matlab, use the command module avail matlab.
Running Matlab Analyses
The typical procedure for performing calculations on UArizona HPC systems is to run your program non-interactively on compute nodes. The easiest way to run Matlab non-interactively is to use input/output redirection. This method uses Linux operators
> to point Matlab to the input file and tell where to write the output (see the example script). The other method is to invoke Matlab from the SLURM script and execute specified statement using
-r option. For details, refer to the manual page for the
-nosplash in the example prevent Matlab from opening graphical elements. To view the full list of options for the
matlab command, load the Matlab module and type
matlab -h at the prompt. Alternatively, use the link above to see the manual page on the MathWorks website.
Parallel Computing Toolbox
By default, Matlab PCT will dump files to
~/.matlab/MATLAB_VERSION. This causes problems when multiple Matlab PCT jobs are running simultaneously. Users should always define the environment variable
MATLAB_PREFDIR so each job uses a unique temporary folder. Files there will be cleaned after the job finishes. For example:
Matlab and SLURM
If you are trying to run Matlab in parallel interactively, you may encounter the following error:
This is caused by an interaction between SLURM and Matlab. To resolve this issue, when requesting <n> cores for your interactive job, you will need to set SLURM's
--ntasks directive to 1 and
--cpus-per-task to the number of cores you need. For example:
If you are getting started with Matlab or think there might be a better way, check out the training resources.
Self-Paced Online Courses
Matlab Parallel Server
Natural Language Processing