From Documentation
(Redirected from Using MATLAB)
Jump to: navigation, search
MATLAB
Description: enables users to write and run MATLAB code for solving data parallel and task parallel applications
SHARCNET Package information: see MATLAB software page in web portal
Full list of SHARCNET supported software


Introduction

MATLAB has introduced a Parallel Computing Toolbox (PCT) that enables users to write and run MATLAB code for solving data parallel and task parallel applications. The MATLAB PCT uses a client-server architecture. The client provides a front end that resembles the traditional MATLAB environment that users are familiar with. The servers – compute engines at the backend – perform the work in a distributed manner. A set of enhanced MATLAB commands and functions for distributed computing have been introduced, which make the parallel processing transparent to users.

Please note that SHARCNET DOES NOT have standalone MATLAB license – only a server side PCT license. This means users cannot run traditional, non-PCT/DCE MATLAB codes on SHARCNET systems unless otherwise licensed.

For users at University of Waterloo(UW), Western University(UWO) and McMaster University, special provisions have been made for access to campus license resources for SHARCNET machines located at those respective sites (See details below). If you have access to the site license at your home institution, you may run MATLAB jobs by compiling your MATLAB code into executable binaries using MATLAB the compiler, mcc, and run the compiled code as regular jobs without further license check (see site specific section below for details).

SHARCNET MATLAB PCT License

General Notes

  • MATLAB PCT is not intended to run regular sequential MATLAB code but for users who want to explore the parallel processing power in running MATLAB applications on supercomputers. Users are expected to start their MATLAB applications on their desktop or workstation and have the computational tasks transferred to and accomplished on SHARCNET's clusters remotely.
  • You have to make sure that your code is efficient to run in parallel using PCT, you can do a performance benchmark on your local machine (PC or whatever machine) as the PCT can run easily via 'matlabpool' on a local multicore machine. You can compare the runtimes (walltime) for 1-cpu/worker (the sequential code) and multiple cpus/workers such as 4 cpus (numprocs=4) and provide us the performance results.
  • We only grant access to those who can provide reasonable performance results.
  • Due to license seeds limitation, we advise user to run 4-cpu or up to 8-cpu (if performance allows) PCT jobs and a few jobs at a time on Sharcnet systems. Otherwise, users may suffer from license checkout error if one or two users used most/all license seeds.

Configuration and Examples

A one time client-side configuration for using the remote resource scheduler on the cluster is required. Details regarding installation/configuration MATLAB PCT and examples can be found from

Using SHARCNET MATLAB PCT.

Western University Site License

Users from Western are covered under the Total Academic Headcount (TAH) licence. Western currently offers access to MATLAB, Simulink, and companion toolboxes. Western users who want to use MATLAB on SHARCNET systems under TAH must first have their Western ID registered with ITS by contacting us prior to every Thursday noon, so that their usernames can be registered by ITS on Friday.

Using MATLAB is restricted to goblin and kraken's bull nodes.

Version Selection

To use MATLAB, first load the module

module load matlab

Job Submission

Interactive job is discouraged. To run a MATLAB job, you must use sqsub command, with option -i matlab_script, e.g.

sqsub -q serial -r 1h -o my_matlab.out -i my_matlab_code.m matlab

To run MATLAB jobs on kraken, use the following command, note the option "-f bul" must be used so that the MATLAB jobs will run on bull nodes where MATLAB is licensed to UWO users

sqsub -q serial -f bul -r 1h -o my_matlab.out -i my_matlab_code.m matlab

Using Multicores

In order to use the parallel programming feature of MATLAB provides, one needs to submit jobs to the threaded queue. The following are sample commands

On goblin:

sqsub -q threaded -n 8 -r 1h -o my_matlab.out -i my_matlab_code.m /opt/sharcnet/local/matlab/R2015a/bin/matlab -nodisplay -nosplash -nojvm

On kraken:

sqsub -q threaded -n 8 -f bul -r 1h -o my_matlab.out -i my_matlab_code.m /opt/sharcnet/local/matlab/R2015a/bin/matlab -nodisplay -nosplash -nojvm

Note, for running multicores, one needs to use the absolute path with the three options shown above.

General Notes

MATLAB Compiler 'mcc'

If you need to run the same code for a number of jobs, i.e., serial farm jobs, you can compile your MATLAB code using 'mcc'. The command to compile code myprog.m will be

mcc -m -R ' -nosplash -nodisplay -nodesktop -nojvm -singleCompThread' myprog

This will create an executable file myprog and a script file run_myprog.sh. To see what other options mcc has, you may use command mcc -help.

To run the executable, you must load the GCC module 4.3 or newer. To resolve a possible conflict, you will need to unload the intel module as suggested when you attempted to load a GCC module:

module unload intel

and then load the GCC module

module load gcc/4.3.4

You can then run myprog as a serial job using sqsub.

sqsub -r 1.0h -o run_myprog.log ./run_myprog.sh [matlabroot] [arguments]

matlabroot is the path to local matlab such as /opt/sharcnet/local/matlab/R2010b

Help

  • The access to MATLAB on goblin and kraken is restricted to Western users only. Users must have the same username as their Western username in order to use the UWO MATLAB site license. For details, please refer to the Western MATLAB site license page on ITS's web site.
  • If you see a license error, please open a ticket on the SHARCNET webportal submit ticket or contact the local staff for immediate attention.

University of Waterloo Site License

Users in UW who have access to UW MATLAB site license UW_IST can run standard MATLAB on orca, saw, mosaic.

Version Selection

UW MATLAB 2015b, 2014a and 2012b are available on orca and mosaic, user side PATH setting is not needed.

Job Submission

  • Prepare a job directory for matlab, i.e., /work/yourid/matlab.
  • Copy the sample executable and test files
cd /work/yourid/matlab 
cp ~jemmyhu/Matlab/uwmatlab .
cp ~jemmyhu/Matlab/matlab_test.m .
  • Using 'sqsub' to submit the job into the default serial queue, use 3GB memory for example
sqsub --mpp=3g -r 1.0d -o matlab_test.log -i matlab_test.m ./uwmatlab

the runscript 'uwmatlab' is simply one line command to run batch job on the cluster, i.e.,

/opt/sharcnet/local/matlab/R2014a/bin/matlab -nodisplay -nosplash -nojvm -singleCompThread

A few simple examples can be found in

/home/jemmyhu/matlab/

General Notes

MATLAB Compiler 'mcc'

The steps to use 'mcc' and run serial farming MATLAB jobs for UW site license on orca are

  • Set up the environments by adding the following two lines to your .bash_profile file, e.g., for R2014a
export PATH=/opt/sharcnet/local/matlab/R2014a/bin:$PATH
export LD_LIBRARY_PATH=/opt/sharcnet/local/matlab/R2014a/runtime/glnxa64/:${LD_LIBRARY_PATH}

logout, then login to orca again

  • Compile your MATLAB code myprog.m on orca's Development Node (ssh to one of orc-dev1, orc-dev2, orc-dev3 or orc-dev4, then go to the directory where your *.m file exists), then run 'mcc' command
ssh orc-dev1
cd /work/yourid/matlab
mcc -m -R ' -nosplash -nodisplay -nodesktop -nojvm -singleCompThread' myprog
#for multiple .m files, use all in mcc
mcc -m -R ' -nosplash -nodisplay -nodesktop -nojvm -singleCompThread' cod21.m code2.m ...
  • Run myprog as a standard serial job using sqsub from login node, using 3GB memory.
sqsub --mpp=3g -r 1.0h -o run_myprog.log ./run_myprog.sh /opt/sharcnet/local/matlab/R2014a [arguments]

Helps

  • If you have any questions/concerns or see a license error, please open a ticket on the SHARCNET webportal submit ticket.

McMaster University Site Licence

For McMaster users who have contributed to the campus license pool, MATLAB is available on Wobbie, Iqaluk and Requin.

Version Selection

To use MATLAB, first load the module

module load matlab

Job Submission

To submit a MATLAB job, you must use sqsub command, with option -i matlab_script, e.g.

sqsub -q serial -r 1h -o my_matlab.out -i my_matlab_code.m matlab

General Notes

MATLAB Compiler 'mcc'

After 'module load matlab', you can compile your MATLAB code myprog.m with command

mcc -m -R '-nosplash,-nodisplay,-nodesktop,-nojvm,-singleCompThread' myprog

This will create an executable file myprog and a script file run_myprog.sh. To see what other options mcc has, you may use command mcc -help. You may wish to omit the "singleCompThread" if your code can effectively use multiple threads.

To run the executable, you must load the GCC module 4.3 or newer. To resolve a possible conflict, you will need to unload the default compiler module as suggested before you attempted to load a GCC module:

module unload pathscale

and then load the GCC module

module load gcc/4.3.4

You can then run myprog as a serial job using sqsub.

sqsub -r 1.0h -o run_myprog.log ./run_myprog.sh [matlabroot] [arguments]

matlabroot is the path to local matlab such as /opt/sharcnet/local/matlab/R2012b

Helps

  • MATLAB license access on Requin happens via a tunnel (since these machines are on SHARCNET's network, not the campus.) This tunnel can die sometimes - if you see a license error, open a ticket on the SHARCNET website submit ticket or email hahn@sharcnet.ca to get it fixed.

MATLAB for non-site license users

For users out of Western, Waterloo, and McMaster, you cannot run the regular MATLAB code at SHARCNET due to license restriction. If you really need to run MATLAB at SHARCNET, the alternatives are

MATLAB Compiler Runtime (MCR)

If your license includes MATLAB compiler, mcc (check the availability under matlabroot/bin/ on your local machine), you can compiler MATLAB codes to be standalone binary code on a Linux system. The standalone executable can be run using the MCR at SHARCNET without license requirement.

SHARCNET has R2012b, R2013b, R2014a, R2016a MCR installed on several systems. Because the version between your mcc and the MCR should match exactly, you have to load the correct version of MCR on SHARCNET clusters. The procedures are

1) compile your code, the mcc command is the same as explained above for the site license users, i.e.,

mcc -m -R ' -nosplash -nodisplay -nodesktop -nojvm -singleCompThread' myprog

2) copy the files generated by mcc to SHARCNET, e.g., your /work directory on SHARCNET cluster

3) module load the match version of MCR, you can add the module load line into your .bash_profile, e.g., for R2012b MCR, it is

module load matlab/R2012b.mcr

exit and login again to effect the change.

4) sbmit as a regular job to the queue on the cluster, or run directly from command line on a viz-workstation

sqsub -r 1.0h -o run_myprog.log ./run_myprog.sh  $mcrroot [arguments]

Use SHARCNET MATLAB PCT License

If you have a client side Parallel Computing Toolbox (PCT) license, and you can modify your code to make use of the Parallel Computing Toolbox (PCT), you can follow the instructions above for SHARCNET MATLAB PCT License to run MATLAB PCT code at SHARCNET without further license requirement.

Use Octave

Explained below

Running MATLAB Code with Octave

If you do not have a MATLAB license and you are not using any MATLAB specific functions or toolboxes, an alternative to run batch MATLAB jobs on SHARCNET is to use Octave[1]. To run a MATLAB code myprog.m, simply type command

octave myprog.m

To submit a job that takes no more than 30 minutes to run, use command

sqsub -q serial -o myprog.out -r 30m octave myprog.m

Octave's syntax is almost 99% compatible with MATLAB. Some minor modifications, however, might be necessary in some cases.

References

o The Mathworks Homepage
http://www.mathworks.com/

o Parallel Computing Toolbox Main
http://www.mathworks.com/products/parallel-computing/

o Submit Matlab Jobs to Sharcnet using Desktop Client
https://www.sharcnet.ca/help/index.php/Using_MATLAB