Using MATLAB on CQLS HPC¶
Introduction to MATLAB on the CQLS infrastructure¶
Users that are looking to work with MathWorks MATLAB software are able to access
it at the command line. First off, MATLAB will not run on the front end machines
shell-hpc.cqls.oregonstate.edu
and files-hpc.cqls.oregonstate.edu
. Users are able to
run the software stack on the processing machines using the -nodisplay
option
when accessing MATLAB via the command line.
The CQLS has several versions currently licensed for command line and batch usage as well as the MATLAB Distributed Computing Server (MDCS). Finally MATLAB only runs on the x86_64 based architecture and will not run on the IBM servers.
MATLAB versions¶
By default the R2023b
is set into the main PATH variable for all users.
Users can access the binaries directly using the following paths for other versions.
- R2018a
-
/local/cluster/MATLAB/R2018a/bin/matlab -nodisplay
-
R2022b
/local/cluster/MATLAB/R2022b/bin/matlab -nodisplay
Users can add the MATLAB folder to their path to e.g. change the default version:
Add the above lines to your ~/.cshrc
or ~/.bashrc
, respectively, to make the
changes persistent across future logins.
Submitting MATLAB jobs to the infrastructure¶
Here is an example of running MATLAB as a batch job where it will multiply 3 times 4 and exit then log the run in a log file. This example the user has submit a job to the cluster through the queuing system.
Note: For more information regarding the queuing system, please see these additional posts:
➜ hqsub "matlab -logfile my_log.out -batch '3*4 , exit'" -r MatLab -q all.q
➜ hqstat
No jobs found for user 'davised' in SGE queue 'None'.
Job Status
┏━━━━━━━┳━━━━━━━━━┳━━━━━━━┳━━━━━━━━━┳━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━━┓
┃ qtype ┃ state ┃ runid ┃ runname ┃ user ┃ code ┃ time ┃ queue@host ┃ cpus ┃ task ┃ jobtype ┃
┡━━━━━━━╇━━━━━━━━━╇━━━━━━━╇━━━━━━━━━╇━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━━┩
│ SLURM │ running │ 60718 │ MatLab │ davised │ R │ 2024-09-09T15:51:40 │ all.q@beech0 │ 2 │ │ batch │
└───────┴─────────┴───────┴─────────┴─────────┴──────┴─────────────────────┴──────────────┴──────┴──────┴─────────┘
➜ cat my_log.out
ans =
12
Using matlab in batch mode on a compute node¶
Note: you must be on a checked out node, e.g. lorax
, using salloc
for this
mode to work.
Here is an example of checking out a node and using MATLAB at the command line:
Same example as from before just working directly on the node in batch and just
run the command mode, e.g. -batch
or -r
option.
$ salloc
$ matlab -logfile my_log.out -batch '3*4 , exit'
ans =
12
14.412u 5.881s 0:12.15 166.9% 0+0k 641160+72io 457pf+0w
$ /local/cluster/MATLAB/R2022b/bin/matlab -nodisplay -r '3*4 , exit' -logfile my_log.out
< M A T L A B (R) >
Copyright 1984-2022 The MathWorks, Inc.
R2022b Update 3 (9.13.0.2126072) 64-bit (glnxa64)
November 17, 2022
To get started, type doc.
For product information, visit https://www.mathworks.com/
ans =
12
17.735u 6.242s 0:09.05 264.8% 0+0k 1200+16792io 6pf+0w
Using matlab in interactive mode¶
Here I just load matlab at the command line on the checked out node and use it interactively.
$ /local/cluster/MATLAB/R2022b/bin/matlab -nodisplay -logfile my_log.out
< M A T L A B (R) >
Copyright 1984-2022 The MathWorks, Inc.
R2022b Update 3 (9.13.0.2126072) 64-bit (glnxa64)
November 17, 2022
To get started, type doc.
For product information, visit https://www.mathworks.com/
>> 3 * 4
ans =
12
>> 5 * 10
ans =
50
>> sin(pi)
ans =
1.2246e-16
>> p = sym(pi)
p =
pi
>> vpa(p, 30)
ans =
3.14159265358979323846264338328
>> exit
27.638u 5.600s 2:31.69 21.9% 0+0k 262336+17176io 79pf+0w