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 |
Contents
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.
SHARCNET DOES NOT have standalone MATLAB license thereore users cannot run traditional, non-PCT/DCE MATLAB codes on SHARCNET systems unless otherwise licensed. SHARCNET does however have a 98 seat server side PCT license (MATLAB Distributed Computing Server) which works in conjuntion with a PCT client toolbox license which the researcher must purchase.
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 sharcnets license seat 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 seats.
Version
R2016b R2014a R2012b
Client Configuration
A one time client-side configuration to use the remote cluster scheduler is required.
R2016b
Here is the procedure for R2016b, similar procedure applies to other versions except for different scripts provided below.
Copy the tar gzip file matlab2016b-config.tar.gz to your client machine. untar/unzip the file, you will have several files within the folder of matlab2016b-config.
For Windows PC/laptop, assuming the install location is
C:\Program Files\MATLAB\R2016b
copy all files to the folder
C:\Program Files\MATLAB\R2016b\toolbox\local\
create a Temp folder for JobStorageLocation on your client machine, i.e. C:\Temp
For MAC OS/Linux client, specify $MATLABROOT to be the location of your MATLAB installation, copy the files to the directory
$MATLABROOT/toolbox/local/
create a Temp folder for JobStorageLocation on your mac machine, i.e. user/Temp
R2014a
Copy the tar gzip file matlab2014a-config.tar.gz to your client machine. untar/unzip the file, follow the same procedure described for R2016b above .
R2012b
Copy the tar gzip file matlab2012ab-config.tar.gz to your client machine. untar/unzip the file, follow the same procedure described for R2016b above.
Example
Example is basically the same for R2016b, R2014a, and R2012b.
For R2016b, copy runscripts_2016b.tar.gz, untar/unzip the file under a 'matlab' work folder on your client machine. The three files are
clusterInfo.m //set up script pTest_14a.m //runscript to run user's code paralleltestfunction.m //user's code
clusterInfo.m is the script to define the compute resource (cpus, memory, runtime), modify the following line accordingly when necessary
clusterHost = 'orca.sharcnet.ca'; //specify the cluster to use remoteJobStorageLocation = '/scratch/jemmyhu/matlab'; // change 'jemmyhu' to your username, create a 'matlab' folder under /scratch/username on the cluster side set(cluster, 'JobStorageLocation', 'C:\Temp'); // on your client machine, change it for mac machine set(cluster, 'HasSharedFilesystem', false); set(cluster, 'ClusterMatlabRoot', '/opt/sharcnet/matlab/R2016b'); //which version to use
To use R2014a, copy runscripts_2014a.tar.gz.
To use R2012b, copy runscripts_2012b.tar.gz.
Run
Start R2016b on your client machine, run 'pTest_16b.m', it will pop up windows asking for
Enter the username Use an identity to login, click 'No' Enter your password
Job will be sent to the remote cluster in the queue 'matlab'. You can login to the cluster and use 'sqjobs' command to see the job status.
As long as the job is in the queue on the cluster, you do not have to wait for result on the client matlab session. You can copy the result back to your local machine after the job is finished.
If you use a different version (R2014a, R2012b), you have to start with the specific version on your machine.
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.
Please note that UW IST has set up a MATLAB license cap on Sharcnet clusters, therefore each user is advised only to run a few jobs (<10?) at a time in order to let other users have a chance to run MATLAB jobs the same time .
Version Selection
UW MATLAB R2016b, R2015b, R2014a and R2012b are available on orca, mosaic and saw, user side PATH setting is not needed.
Job Submission
submit a job to the scheduler using sqsub
- 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., for R2014a:
/opt/sharcnet/local/matlab/R2014a/bin/matlab -nodisplay -nosplash -nojvm -singleCompThread
A few simple examples can be found in
/home/jemmyhu/matlab/
Run interactive MATLAB jobs on mosaic
First, you can choose which MATLAB version to use and add it to your PATH, e.g., for R2016b, add the following line to the end of your .bash_profile file (this is a one time setting)
export PATH=/opt/sharcnet/local/matlab/R2016b/bin:$PATH
exit and login in again to check for the setting by typing 'which matlab', it should give
[jemmyhu@mos1:~] which matlab /opt/sharcnet/local/matlab/R2016b/bin/matlab
Second, MATLAB window is a graphical application, each time when you login, you have to enable X11 forwarding (enable client X-Window) before login to Mosaic. If you login from a mac or linux client, you should add -Y to ssh. i.e.,
ssh -Y username@mosaic.sharcnet.ca
There are two ways to run interactive MATLAB jobs on mosaic. One is to ssh to the dev-node mos1
ssh -Y mos1
Run interactive matlab on mos1
[jemmyhu@mos1:~] matlab
The second way is to reserve a node for interactive jobs, you can submit a "sleep <seconds>" program to the gpu queue with no output file like this:
[jemmyhu@mos-login:~] sqsub -q gpu -f threaded -n 20 --gpp=1 --mpp=150g -r 10h -o /dev/null sleep 36000
This will reserve a full single node for 10 hours, and it runs the sleep command as a placeholder in the scheduler. The sleep command should be set to run for as long as your reservation is set - in this case, 60 seconds * 60 minutes * 10 hours = 36000.
Once the job starts running, you can use sqjobs to check which node the job is running:
[jemmyhu@mos-login:~] sqjobs jobid queue state ncpus nodes time command ------ ----- ----- ----- ----- ---- ------- 304617 gpu R 20 mos5 208s sleep 36000
And then use ssh -Y to login to that node. Please be sure you add -Y before you login to that node.
[jemmyhu@mos-login:~] ssh -Y mos5 [jemmyhu@mos5:~] 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
module load R2014a.mcr 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 $mcrroot [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 R2014a MCR, it is
module load matlab/R2014a.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