NERSCPowering Scientific Discovery Since 1974

Matlab

Description and Overview


MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. MATLAB features a family of add-on application-specific solutions called toolboxes. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. These are the toolboxes installed in NERSC MATLAB, along with the number of licenses.

Toolbox Number of Licenses
Image Processing 2
Neural Networks 1
Optimization 2
Parallel Computing 2
Signal Processing 1
Statistics 2

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix computation.

How to Use Matlab

Matlab is available at NERSC on Carver, Hopper, and Edison.  The number of Matlab licenses at NERSC is not very large, so users should not be running a Matlab session when it is not being actively used. 

Use Matlab on Carver

On Carver, type the following commands to use Matlab:

% module load matlab
% matlab

Memory usage is tightly restricted on Carver. Carver's login nodes have hard limits of 2GB per process, and by default compute nodes do as well. On login node the full 2GB may be made available from with shell specific commands. For example in bash:

% ulimit -S {-d,-m,-v,-s} unlimited

In the csh shell use the limit command.

On compute nodes hard resource limits may be modified in the qsub command. For example, the following command sets the hard limit at 20GB.

% qsub -I -X -V -q interactive -l nodes=1:ppn=1 -l walltime=00:30:00 -l pvmem:20GB

Matlab can also be run non-interactively as a batch job. This is useful for long calculations that run a Matlab script. When Matlab is run as a batch job the X graphical interface must be disabled and the format for loading matlab scripts is slightly different. The script below illustrates how to submit a Matlab job to the serial queue on carver.

#PBS -q serial
#PBS -l pvmem=10GB
#PBS -l walltime=10:00:00
#PBS -N matlab_test
#PBS -e matlab_test.$PBS_JOBID.err
#PBS -o matlab_test.$PBS_JOBID.out
#PBS -V

module load matlab
matlab -nodesktop -nosplash < yourmatlabscript.m > matlab_output.txt

Use Matlab on Hopper and Edison

Matlab is available on Hopper and Edison under the Cluster Compatibility Mode (CCM).  Matlab can run on a compute node with exclusive access to the full usable memory (about 30 GB on most Hopper nodes and 62 GB on Edison nodes) by submitting a batch job to the "ccm_int" or "ccm_queue" queue.

To run Matlab interactively,

% qsub -I -V -q ccm_int -l walltime=30:00
% module load matlab
% ccmlogin -V
% matlab

To run matlab non-intearctively through a batch job, you can use the following job script:

#!/bin/bash -l 
#PBS -q ccm_queue
#PBS -l mppwidth=24,walltime=2:00:00
#PBS -N test_ccm
#PBS -j oe
#PBS -V

cd $PBS_O_WORKDIR
module load ccm
export CRAY_ROOTFS=DSL
module load matlab

ccmrun matlab -nodisplay -r myjob -logfile myjob.log

Where myjob.m is your matlab script. It is also possible to run Matlab on an Edison login node (but not recommended on Hopper login node due to its smaller memory available) directly:

% module load matlab
% matlab

How to Run Matlab in Parallel

The following program illustrates how matlab can be used in parallel. NERSC's license currently limit parallel use to a single node and at most 12 threads.

% hello-world.m
matlabpool open 8
spmd
  rank=labindex;
  fprintf(1,'Hello %d\n',rank);
end
matlabpool close

For loop level parallelism Matlab provides the parfor construct.

In order to make matlab work in parallel on Edison and Hopper, you need to make sure it will access the Matlab libraries before the standard cray libraries. You can do this by running this command for bash:

export LD_PRELOAD="/global/common/carver/usg/matlab/R2012a/bin/glnxa64/libmpichnem.so /global/common/carver/usg/matlab/R2012a/bin/glnxa64/libmpichsock.so"

or for csh / tcsh:

setenv LD_PRELOAD "/global/common/carver/usg/matlab/R2012a/bin/glnxa64/libmpichnem.so /global/common/carver/usg/matlab/R2012a/bin/glnxa64/libmpichsock.so"

However, if you have LD_PRELOAD set on a login node, this will interfere with the regular Edison and Hopper environment. It's important that you only set the LD_PRELOAD variable in your parallel Matlab job script (or interactive job).

Documentation

Extensive on-line documentation is available. You may subscribe to the MATLAB Digest, a monthly e-mail newsletter by sending e-mail to subscribe@mathworks.com.

Availability

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
MATLAB carver applications/ visualization R2010a matlab/R2010a 2010-05-21 2010-05-21
MATLAB carver applications/ visualization R2010a matlab-nofonts/R2010a 2012-01-10 2012-01-12
MATLAB carver applications/ visualization R2010b matlab/R2010b 2012-01-10
MATLAB carver applications/ visualization R2010b matlab-nofonts/R2010b 2012-01-10
MATLAB carver applications/ visualization R2011b matlab/R2011b 2012-01-10 2012-01-18
MATLAB carver applications/ visualization R2011b matlab-nofonts/R2011b 2012-01-10 2012-01-18
MATLAB carver applications/ visualization R2012a matlab-nofonts/R2012a 2012-04-06 2012-04-11
MATLAB carver applications/ visualization R2012a matlab/R2012a 2012-04-02 2012-04-11
MATLAB edison applications/ visualization R2011b matlab_ccm/R2011b 2013-04-12
MATLAB edison applications/ visualization R2011b matlab/R2011b 2013-04-12
MATLAB edison applications/ visualization R2011b matlab-nofonts/R2011b 2013-04-17
MATLAB edison applications/ visualization R2012a matlab_ccm/R2012a 2013-04-12 2013-04-12
MATLAB edison applications/ visualization R2012a matlab/R2012a 2013-04-12 2013-04-12
MATLAB edison applications/ visualization R2012a matlab-nofonts/R2012a 2013-04-17 2013-04-17
MATLAB hopper applications/ visualization R2011b matlab_ccm/R2011b 2012-04-04
MATLAB hopper applications/ visualization R2011b matlab/R2011b 2013-04-12
MATLAB hopper applications/ visualization R2012a matlab_ccm/R2012a 2012-04-04 2012-04-04
MATLAB hopper applications/ visualization R2012a matlab-nofonts/R2012a 2013-06-20 2013-06-20
MATLAB hopper applications/ visualization R2012a matlab/R2012a 2013-04-12 2013-04-12
matlab pdsf_sl6 applications/ programming R2012a matlab/R2012a 2013-12-12 2013-12-12