Contents

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.cqls.oregonstate.edu and files.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 two versions R2022b and R2018a 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 R2022b is set into the main PATH variable for all users.

1
%:~x86~:jackson> matlab -nodisplay

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:

TCSH

1
setenv PATH "/local/cluster/MATLAB/R2018a/bin:$PATH"

BASH

1
export PATH = "/local/cluster/MATLAB/R2018a/bin:$PATH"

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
%:~x86~:vaughan> SGE_Batch -c "matlab -logfile my_log.out -batch '3*4 , exit'" -r MatLab
%:~x86~:vaughan> qstat
job-ID  prior   name       user         state submit/start at     queue                          slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
 119041 0.00000 MatLab     sullichr     qw    02/14/2023 15:28:25                                    1       
%:~x86~:vaughan> qstat
job-ID  prior   name       user         state submit/start at     queue                          slots ja-task-ID
-----------------------------------------------------------------------------------------------------------------
 119041 0.50500 MatLab     sullichr     r     02/14/2023 15:28:35 jackson@jackson.cgrb.oregonsta     1       
%:~x86~:vaughan>qstat
%:~x86~:vaughan> cat MatLab/MatLab.o119041
  Started on:            jackson
  Started at:            Tue Feb 14 15:30:50 PST 2023

ans =

    12

  Finished at:            Tue Feb 14 15:30:59 PST 2023
%:~x86~:vaughan>

Using matlab in batch mode on a compute node

Note: you must be on a checked out node, e.g. lorax, using qrsh 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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[Linux@vaughan ~]$ qrsh
[Linux@lorax ~]$ 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
[Linux@lorax ~]$ 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
[Linux@lorax ~]

Using matlab in interactive mode

Here I just load matlab at the command line on the checked out node and use it interactively.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[Linux@lorax ~]$ 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
[Linux@lorax ~]$