MATLAB is installed on the Strelka Computer Cluster.  To make full use of the cluster, you may need to use the MATLAB Parallel Computing Toolbox to take advantage of parallel execution and GPU capabilities.  

Loading MATLAB module

To run MATLAB code, first load the module:

Run this after logging in to Strelka
module load matlab

Running with a Graphical User Interface

If you want to run the MATLAB graphical user interface (as opposed to the command line), connect to Strelka with X11.

macOS and Linux Users

Connect to Strelka using the following command on your computer (replace "username" with your Swarthmore username).  

ssh -XYC

On a Mac, you may need to install XQuartz if it isn't already on your system:


Setting up X11 forwarding for Windows

Starting MATLAB

To start MATLAB, make sure to load the MATLAB module (see above) and then type:


The graphical user interface will load on your computer.

Testing MATLAB Code

On login node, use this command to run a .m file.  Only run small, short jobs on the login node because it is shared with all the other Strelka users.

matlab -batch "run('matlab_test.m'); exit" 

Submission Script Example

For larger jobs, submit a MATLAB job to Slurm. Example job submission script:

#! /bin/bash
#SBATCH -t 1:00:00
#SBATCH -n 1
#SBATCH -p compute 
#SBATCH --output=./output/output_%j.log
cd $HOME/matlab_test
module load matlab
matlab -batch "run('./matlab_test.m');exit" >> ./output/testcode.out.$SLURM_JOB_ID

See the main Strelka page for more details about how to configure a the Slurm submission script.  

Parallel Computing Toolbox 

Some tips:

MATLAB Parallel Computing Toolbox will save files to a default location in your home folder (~/.matlab/MATLAB_VERSION).  This can cause problems if multiple jobs are running at once because more than one process may attempt to modify preference files at the same time.  To avoid problems, specify a directory with the job id using the MATLAB_PREFDIR environmental variable.  For example, add this line to the job submission script before the command to execute your code.  

#  Ensure matlab data directory exists
mkdir -p $HOME/matlabdata

mkdir $HOME/matlabdata/$SLURM_JOBID
  • No labels