- This guide will cover how to load and run
- To load MATLAB:
module load matlab/r2019a
- To run MATLAB:
matlab -nodisplay -batch <input file>
Part 1: The PBS Script¶
#!/bin/bash #PBS -N testMATLAB #PBS -A [Account] #PBS -l nodes=1:ppn=2 #PBS -l pmem=2gb #PBS -l walltime=2:00 #PBS -q inferno #PBS -j oe #PBS -o testMATLAB.out cd $PBS_O_WORKDIR module load matlab/r2019a matlab -nodisplay -batch testfile
In this case, our MATLAB file
matlab_test.m will be very simple, but the process is similar for most MATLAB scripts.
#PBSdirectives are standard, requesting just 2 minutes of walltime and 1 node with 2 cores. More on
#PBSdirectives can be found in the PBS guide
$PBS_O_WORKDIRis simply a variable that represents the directory you submit the PBS script from.
Make sure the
.m file you want to run is in the same directory you put the PBS script. Additionally, make sure not to include the extension for the file in
the PBS script.
- Output Files will also show up in the same directory as the
module load matlab/r2019aloads the specified MATLAB version
matlab -nodisplay -batch matlab_testruns MATLAB without the display and executes a non-interactive batch script named
Part 2: Submit Job and Check Status¶
- Make sure you're in the directory that contains the
PBSscript and the
- Submit as normal, with
qsub <pbs script name>. In this case
- Check job status with
qstat -u username -n, replacing "username" with your gtusername
- You can delete the job with
qdel #, replacing the number with the jobid returned after running qsub
Part 3: Collecting Results¶
- In the directory where you submitted the
PBSscript, you should see a newly generated file once your job is completed named
- Take a look at testMATLAB.out using any text editor, such as vim with
vim testMATLAB.outor output to the terminal using
- It should include the printed "Hello World!" statement.
To Run MATLAB Interactively On Cluster¶
- Please see the VNC guide for instructions on how to set up the Interactive VNC session
Start Matlab on VNC¶
- Open terminal in vnc window by clicking top left
System Tools> scroll down to
- All commands here on will be typed in terminal in VNC
- To see available versions of matlab run
module avail matlab
- Load matlab module and start matlab
module load <version of matlab> #example: module load matlab/r2020b matlab
- The MATLAB GUI will load on screen.
Set Up Parallel Environment MATLAB¶
- For larger or longer multi-node jobs, use distributed MATLAB for parallel computing. This is the recommended path.
- You can also use a parallel pool within your single interactive job, based on the number of cores you requested on a single node for your interactive job.
- It will start automatically when functions such as
- Read more about managing parallel pools here.
Control the Parallel Pool from the Matlab Desktop¶
- Access pool preferences in the Home tab in the Environment section, go to Parallel > Parallel Preferences
- To open a parallel pool based on your preference settings, use
- To open a pool of a specific size, use
- These can be used in the command-line interface or when writing a Matlab script
- More information about using parpool can be found here