Updated 2023-03-31
MATLAB¶
Overview¶
- This guide cover how to load and run
matlab/r2021a
Summary¶
- To load MATLAB:
module load matlab/r2021a
- To run MATLAB:
matlab -nodisplay -batch <input file>
SBATCH
Script can be found here.
Part 1: The SBATCH Script¶
#!/bin/bash
#SBATCH -JtestMATLAB
##SBATCH -A [Account]
##SBATCH -N 1 --ntasks-per-node=2
#SBATCH --mem-per-cpu=2G
#SBATCH -t2
#SBATCH -qinferno
#SBATCH -oReport-%j.out
cd $SLURM_SUBMIT_DIR
module load matlab/r2021a
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.
fprintf("Hello World!")
- The #SBATCH directives are standard, requesting just 2 minutes of walltime and 1 node with 2 cores. More on #SBATCH directives can be found in the Using Slurm on Phoenix Guide
$SLURM_SUBMIT_DIR
is is simply a variable that represents the directory you submit the SBATCH script from.
Warning
Make sure the .m
file you want to run is in the same directory you put the SBATCH script. Additionally, make sure not to include the extension for the file in the SBATCH script.
- Output Files will also show up in the same directory as the
SBATCH
script module load matlab/r2021a
loads the specified MATLAB version- Check job status with
squeue --job <jobID>
, replacingthe jobid returned after running sbatch - You can delete the job with
scancel <jobID>
, replacing the number with the jobid returned after running sbatch
Part 3: Collecting Results¶
- In the directory where you submitted the
'SBATCH'
script, you should see a newly generated file once your job is completed namedReport-<jobID>.out
- Take a look at testMATLAB.out using any text editor, such as vim with
vim Report-<jobID>.out
or output to the terminal usingcat Report-<jobID>.out
- It should include the printed "Hello World!" statement.
To Run MATLAB Interactively On Cluster¶
Set up MATLAB on Phoenix OnDemand¶
- In order to access Phoenix OnDemand you must be connected to the GT VPN. If you do not already have the VPN set up, visit Configure the GT VPN
- Once connected to the VPN you can access the application at Phoenix OnDemand.
- Choose the
Slurm Interactive Apps
tab and selectMatlab
to setup and launch. - Setting up Matlab:
- Charge Account:
gts-<PI username> ("phx-pace-staff" works for trial. Required.)
- Quality of Service:
inferno
- Node Type:
GPU Tesla V100-16B or GPU Tesla V100-32B
- Nodes:
1
- Cores Per Node:
1 (Number of cores (CPUs) per node. Max: 24 cores per node.)
- GPUs Per Node:
1
- Memery Per Crore (GB):
Leave blank if unsure. Total memory for job is: nodes × cores × memory per core
- Number of hours:
1
- Charge Account:
- After the preceding details are entered, click the
Launch
button - Once the
Launch Matlab
button is an available option, click the button to open a Phoenix OnDemand Interactive Desktop to use for 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
parfor
are run. - 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
PROGRAMMING INTERFACE¶
- To open a parallel pool based on your preference settings, use
parpool
- To open a pool of a specific size, use
parpool(4)
8 These can be used in the command-line interface or when writing a Matlab script - More information about using parpool can be found here