Using MATLAB on Cherry Creek

Matlab is not installed on the head node.

The recommended method for running Matlab is through a PBS batch session. Running Matlab as an interactive session via pbs especially with X windows can have a high latency, resulting in poor interactive performance.

Note: this is a batch (non-interactive) job, if you must use an interactive job,
see (Interactive Usage
) below for more information.

Create a file called TestBlas.pbs with the following lines.

cat <<EOF >TestBlas.pbs
#!/bin/bash
#
#PBS -l ncpus=1,mem=16gb,cput=1:0:0 -l walltime=1:0:0
module load matlab
export BLAS_VERSION=/share/apps/intel/mkl/lib/intel64/libmkl_rt.so
cp TestBlas.m $TMPDIR
cd $TMPDIR
matlab < TestBlas.m
exit 0
EOF

Create a matlab command file called: TestBlas.m:

cat <<EOF >TestBlas.m
echo on A = rand(10000,10000);
B = rand(10000,10000);
tic
C=A*B;
toc
A = rand(20000,20000);
B = rand(20000,20000);
tic
C=A*B;
toc
A = rand(30000,30000);
B = rand(30000,30000);
tic
C=A*B;
toc
exit
EOF


The above creates a bash script with the necessary PBS options. Copies the matlab command file to a temporary directory on the PBS assigned compute node. Then executes matlab command file from the temporary directory.

Running the Example batch job

After creating the TestBlas.pbs and TestBlas.m files, to submit the
job for processing, use the "qsub TestBlas.pbs" command, like so:

[user@cherry-creek ~]$ qsub TestBlas.pbs
43086.cherry
[user@cherry-creek ~]$ qstat 43086

Job id            Name             User              Time Use S Queue
----------------  ---------------- ----------------  -------- - -----
43086.cherry      TestBlas.pbs     user               00:00:00 R workq
[user@cherry-creek ~]$

Your job has finished when you see something similar to the following:

[user@cherry-creek ~]$ qstat 43086
qstat: 43086.cherry Job has finished, use -x or -H to obtain historical job information
[user@cherry-creek ~]$

At this point you the output from your batch job is located in the "TestBlas.pbs.e43086" (stderr)
and "TestBlas.pbs.o43086" (stdout) files. You can see the output by using the "more" command:

more TestBlas.pbs.o430866

Running Matlab on cherry-creek interactively

As mentioned above, the preferred method of running Matlab is as a batch job, but if you need to do it interactively do something like: (after logging into cherry-creek -- the qsub command is entered on a single line):

[user@cherry-creek ~]$ qsub -I -l ncpus=1,mem=16gb,cput=1:0:0 -l walltime=1:0:0 /bin/bash
qsub: waiting for job 43090.cherry to start
qsub: job 43090.cherry ready

[user@cp-119-9 ~]$ module load matlab
[user@cp-119-9 ~]$ export BLAS_VERSION=/share/apps/intel/mkl/lib/intel64/libmkl_rt.so
[user@cp-119-9 ~]$ matlab


MATLAB is selecting SOFTWARE OPENGL rendering.

< M A T L A B (R) >
Copyright 1984-2022 The MathWorks, Inc.
R2022a Update 4 (9.12.0.2009381) 64-bit (glnxa64)
July 7, 2022


To get started, type doc.
For product information, visit www.mathworks.com.
>> matlab commands should be entered here
>> exit
[user@cp-119-9 ~]$ exit

qsub: job 43090.cherry completed
[user@cherry-creek ~]$

The "qsub -I" is entered on the cherry-creek front-end and then opens up a shell session on another node (in this case cp-119-9). The commands between "module" and the second "exit" are then entered on the other node.

If your session is setup to receive forwarded X windows then the qsub -X option can be used to open matlab in X windows.