Jump to content

Running MATLAB on Firebird: Difference between revisions

From Swarthmore Knowledge Base
Imported from Confluence
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
__TOC__
MATLAB can be run on Firebird in three ways: interactively via a GUI, interactively on the command line, or unattended batch.
MATLAB can be run on Firebird in three ways: interactively via a GUI, interactively on the command line, or unattended batch.


Line 11: Line 9:
Typically the best option to run MATLAB interactively with a GUI is to use Open OnDemand. Follow the [[Open OnDemand|steps outlined here]] to launch a virtual desktop through Open OnDemand. Open a terminal and load the MATLAB module:
Typically the best option to run MATLAB interactively with a GUI is to use Open OnDemand. Follow the [[Open OnDemand|steps outlined here]] to launch a virtual desktop through Open OnDemand. Open a terminal and load the MATLAB module:


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash" copy>
module load matlab
module load matlab
</syntaxhighlight>
</syntaxhighlight>
Line 17: Line 15:
To launch MATLAB:
To launch MATLAB:


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash" copy>
matlab
matlab
</syntaxhighlight>
</syntaxhighlight>
Line 58: Line 56:
=== Windows ===
=== Windows ===


[https://swatkb.atlassian.net/wiki/display/ACADTECH/Connect+to+Strelka+from+Windows#ConnecttoStrelkafromWindows-InstructionstosetupX11forwarding Setting up X11 forwarding for Windows]
[[Running Graphical Applications on Firebird|Setting up X11 forwarding for Windows]]


=== Starting MATLAB ===
=== Starting MATLAB ===
Line 78: Line 76:
You can submit a file with MATLAB commands; in this example, that file is named <code>matlab_test</code>, and this job submit file might be named <code>matlab_job.sh</code>.
You can submit a file with MATLAB commands; in this example, that file is named <code>matlab_test</code>, and this job submit file might be named <code>matlab_job.sh</code>.


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash" line copy>
#! /bin/bash
#! /bin/bash
#SBATCH -t 1:00:00
#SBATCH -t 1:00:00
Line 94: Line 92:
This is a basic example script and will likely need to be further modified for your specific needs. Once you have a job script, you can submit it to Slurm via:
This is a basic example script and will likely need to be further modified for your specific needs. Once you have a job script, you can submit it to Slurm via:


<syntaxhighlight lang="text">
<syntaxhighlight lang="bash" copy>
sbatch matlab_job.sh
sbatch matlab_job.sh
</syntaxhighlight>
</syntaxhighlight>


 
[[Category:Firebird Software]]
[[Category:Teaching, Learning, Research]]
 
 
<!-- Imported from Confluence page id=20909489 (https://swatkb.atlassian.net/wiki/spaces/ACADTECH/pages/20909489/Running+MATLAB+on+Firebird) -->

Latest revision as of 20:32, 12 June 2026

MATLAB can be run on Firebird in three ways: interactively via a GUI, interactively on the command line, or unattended batch.

Running Interactively with a GUI / Virtual Desktop

MATLAB can be run interactively in two ways. The preferred way is through a virtual desktop with Open OnDemand, though X11 on a local system is another option.

Open OnDemand

Typically the best option to run MATLAB interactively with a GUI is to use Open OnDemand. Follow the steps outlined here to launch a virtual desktop through Open OnDemand. Open a terminal and load the MATLAB module:

module load matlab

To launch MATLAB:

matlab

X11

It is also possible to launch a GUI interface from your local system via SSH/X11, though this is typically substantially less performant than using a virtual desktop through Open OnDemand. Instructions for doing so differ depending on your system’s operating system.

macOS and Linux Users

On a Mac, you may need to install XQuartz if it isn't already on your system: https://www.xquartz.org/

Windows

If using Windows, first configure X11 depending on your client.

Once X11 support is configured, whether using Mac, Linux, or Windows, connect via SSH, request time on a node, making sure to pass the --x11 flag (adjust options as needed), and launch MATLAB:

ssh -XYC username@firebird.swarthmore.edu
[user@firebird ~]$ salloc -t 60 --cpus-per-task=1 --mem-per-cpu=32gb --partition=unowned --x11
matlab

The GUI interface should open locally:

Command Line

To use MATLAB interactively through a command line, connect to Firebird via SSH. Load the module, connect to a compute node, and then launch MATLAB:

module load matlab
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 Firebird with X11.

Windows

Setting up X11 forwarding for Windows

Starting MATLAB

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

matlab

The graphical user interface will load on your computer.

Unattended Batch

It is possible to submit a script that will run within MTLAB, using Slurm.

Submission Script Example

You can submit a file with MATLAB commands; in this example, that file is named matlab_test, and this job submit file might be named matlab_job.sh.

#! /bin/bash
#SBATCH -t 1:00:00
#SBATCH -n 1
#SBATCH -N 1
#SBATCH -p compute
#SBATCH --output=./output/output_%j.log

cd $HOME/matlab_test
module load matlab

matlab -batch "matlab_test" >> ./output/testcode.out.$SLURM_JOB_ID

This is a basic example script and will likely need to be further modified for your specific needs. Once you have a job script, you can submit it to Slurm via:

sbatch matlab_job.sh