Skip to end of metadata
Go to start of metadata

Using Matlab on the cluster

A site-wide license for Matlab is administered by the University at Albany. Matlab can be run on the cluster "interactively", with the GUI via X11 forwarding, or Matlab scripts can be submitted to the cluster as jobs using SBATCH. For more information on connecting to the cluster via SSH, please see How-to: Connect via SSH (PuTTY, macOS terminal, X2Go)

Interactive Matlab

Running Matlab interactively requires a connection via SSH with X-forwarding. In the below examples, an Interactive Matlab session running on the cluster is demonstrated using X2Go with MATE desktop.

  1. Connect to with X-forwarding. To do this from X2Go with MATE desktop, open a terminal and run

    ssh -X

  2. Next, request an interactive allocation on the cluster using "srun". For more information, please see: How do I schedule an interactive job? Here, we are requesting one node on batch, with 12 cpus, 2GB of memory, a time limit of 8 hours, and --pty --x11.

    srun --partition=batch --nodes=1 --time=08:00:00 --cpus-per-task=12 --mem=2000 --pty --x11 $SHELL -i


    Note: You can request access to the GPUs on --partition=batch or --partition=ceashpc by adding the following flag:

    --gres=gpu:1 # For one GPU

    --gres=gpu:2 # For two GPUs, given the NVIDIA K80's are 2 K40's with 24GB of shared memory

  3. Now, we'll use the matlab module file to load matlab 2019a, via "module load matlab/2019a"

    module load matlab/2019a

    To see what modules are available, type "module avail"

  4. Finally, type "matlab" and the GUI will spawn

Example SLURM Script

#SBATCH -p batch #batch partition
#SBATCH --cpus-per-task=12 # 12 cores
#SBATCH --mem-per-cpu=2000 # 2GB memory
#SBATCH --mail-type=ALL
#SBATCH #email address
#SBATCH -o /network/rit/home/%u/example-slurm-%j.out #log file
#SBATCH --time=1-0:1 # Estimating the job will take 1 day, 0 hours, 1 minute
# source matlab module
module load matlab/2019a
#Run the script
matlab -nodesktop -nosplash -batch [your_script].m