Skip to content

MATLAB

MATLAB holds significant importance in both, research and student communities as an important tool for scientific computing.

GUI jobs

MATLAB can be used using !noMachine interface which is the GUI based interface to access VSC. (Learn more about !noMachine here ).

Once a !noMachine session opens, following commands will open a MATLAB,

module purge
module load Matlab/<version>
gpurender matlab &

You can run 16 parallel workers/threads/processes on GUI VSC4 and 32 parallel workers/threads/processes and GUI VSC5. Please note, that here the maximal amount of RAM is 256 GB.

JupyterLab jobs

With JupyterLab, the nodes and cores are preconfigured for initial parallel programming steps.

i.e

  • Use "VSC-5 (conda python env) in Select profile to use
  • Use "Conda MATLAB jupyterhub-matlab (Python 3.11.7)" in Conda env to use
  • Choose the number of physical cores, memory and maximum running time as needed.
  • Then select launcher to open MATLAB.

Moreover, JupyterLab allows us to submit jobs to the cluster, providing an opportunity to learn the basics of SLURM jobs right from the JupyterLab interface. Click HOME -> Parallel -> Create and manage Clusters you can add your desired Cluster Profile: You can change settings like Partition, QOS, Cluster by →edit ... and modify them within JupyterLab and then you can run your code from there (do not forget to select your Cluster profile before you press the RUN Button),

Change the qos, nodes, partitions etc accordingly. (Learn more about these from this page).

Batch jobs

The following script is a simple example to use the .m file in batch mode with MATLAB.

Here, you can specify the desired partitions, cores, and nodes without the need for elaborate configurations in JupyterLab. To keep it simple as possible, the notation should be: the input files with file extension .m, batch jobs have the file extension .job and the output files may be also MATLAB files.

#!/bin/bash
#SBATCH -J test1 
#SBATCH -N 1
#SBATCH -q zen3_0512
#SBATCH -p zen3_0512

module purge
module load Matlab/v9.14_REL2023a

matlab < main.m

To be submitted using

sbatch my_matlab.job

Commandline

Create a test.m file

add(2,3.4)
and a function add.m,

function z=add(x,y)
z=x+y

The following command on login node gives a quick way of testing small scripts.

module purge
module load Matlab/(...Version...)
matlab -nodisplay
run test.m