MATLAB is a university-wide licensed software that is also available on ODU HPC clusters. MATLAB is available also on MoVE and many lab computers in caompus. But we recommend using our HPC environment to perform heavy-duty computation and data analysis with MATLAB.
This wiki article is focused on basic instructions on running MATLAB on HPC environment. There are several approaches to running MATLAB. Please consider your use case and pick the most appropriate one.
Please load the matlab
module first:
module load container_env matlab
There are a few versions of MATLAB available on the cluster; invoke module spider matlab
to get the list of available versions, and choose the appropriate one for your application.
As a starting point, here's an example job script to run an example MATLAB script named hello_matrix.m1
(download source):
#!/bin/bash -l
#
#SBATCH -N 1
#SBATCH -c 1
#SBATCH -J hello_matrix
#SBATCH -o %x.out%j
#
# A sample MATLAB job on Turing or Wahab
module load container_env matlab
matlab -nodisplay -nodesktop -batch hello_matrix
Suppose you have a script named my_calc.m
to run noninteractively on HPC.
You can do this using the -batch
option of MATLAB:
$ matlab -batch my_calc
This applies to both interactive or batch jobs.
Do NOT include the
.m
extension on the program name; that will be deduced by MATLAB.
Matlab supports interactive session without GUI. After you obtain your compute resource using salloc
, issue the following command:
$ matlab -nodisplay -nodesktop
Then you are ready to issue MATLAB commands to try interactively.
Running Matlab with the GUI is the most common mode of using Matlab. After you obtain your compute resource using salloc
, issue the following command:
$ matlab
You will need to use the Remote Desktop Protocol (RDP) interface to use Matlab in a GUI mode. Open a terminal from the desktop, and invoke the salloc
and matlab
commands above.
There are two ways to use multiple CPU cores in MATLAB to speed up calculations.
This is the most straightforward. You simply specify the #SBATCH -c NNN
(NNN = number of CPU cores) in your job script. Many MATLAB functions can recognize and utilize the availability of multiple cores. Explicit parallelism can be specified using the parfor
statement.
This feature is not supported by our license at the moment.