- This guide cover how to load and run
- To load MATLAB:
module load matlab/r2021a
- To run MATLAB:
matlab -nodisplay -batch <input file>
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.
- 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_DIRis is simply a variable that represents the directory you submit the SBATCH script from.
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
module load matlab/r2021aloads the specified MATLAB version
- Check job status with
squeue --job <jobID>, replacing
the 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 named
- Take a look at testMATLAB.out using any text editor, such as vim with
vim Report-<jobID>.outor output to the terminal using
- 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 Appstab and select
Matlabto setup and launch.
- Setting up Matlab:
- Charge Account:
gts-<PI username> ("phx-pace-staff" works for trial. Required.)
- Quality of Service:
- Node Type:
GPU Tesla V100-16B or GPU Tesla V100-32B
- Cores Per Node:
1 (Number of cores (CPUs) per node. Max: 24 cores per node.)
- GPUs Per Node:
- Memery Per Crore (GB):
Leave blank if unsure. Total memory for job is: nodes × cores × memory per core
- Number of hours:
- Charge Account:
- After the preceding details are entered, click the
- Once the
Launch Matlabbutton 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
- 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
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