Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Using MATLAB in O2

If you are primarily interested in using the interactive graphical version of MATLAB on O2, it is easiest and most performant to use O2’s web interface, known as O2 Portal.

Otherwise, to use MATLAB via the command line, please continue reading:

MATLAB is a resource-intensive application, and MUST ALWAYS be run on O2's computing nodes, not the login nodes. This can be done submitting a job through the SLURM scheduler as explained in detailed below.

...

Code Block
#-----------------------------------------------------
#SBATCH -p short
#SBATCH  -t 1:00:00
#SBATCH --mem=8000
#SBATCH -c 1

module load matlab/2019a2021b
matlab -batch "myfunction(my_inputs)"
#-----------------------------------------------------

...

Using MATLAB Desktop (GUI) in O2

When running interactive MATLAB jobs it It is possible to display the graphical version of MATLAB back to your desktop using X11 forwarding, however this is not recommended, since it is known to crash frequently when heavy graphics need to be displayed.

A more resilient and better performing option is to run MATLAB as part of a Jupyter notebook/ lab. To set up the MATLAB-Jupyter interface you can follow the instruction described in Jupyter on O2 making sure to load the MATLAB module and install the additional package jupyter-matlab-proxy after installing Jupyter.

Code Block
module load gcc/6.2.0 python/3.7.4 matlab/2021b
virtualenv jupytervenv
source jupytervenv/bin/activate
pip3 install jupyter
pip3 install jupyter-matlab-proxy

...

or

...

after selecting the MATLAB option you should see a screen like:

...

which can last for a few minutes and will eventually start the MATLAB Desktop interface:

...

now possible to run MATLAB in O2 with its Desktop GUI interface using our O2 Portal MATLAB applications. For more information please check our O2Portal wiki