From Documentation
Jump to: navigation, search
(Western University Site License)
(Western University Site License)
 
(62 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 +
{{Template:CCDelete}}
 
{{Software
 
{{Software
 
|package_name=MATLAB
 
|package_name=MATLAB
|package_description= enables users to write and run MATLAB code for solving data parallel and task parallel applications
+
|package_description= MATLAB
 
|package_idnumber=54
 
|package_idnumber=54
 
}}
 
}}
 
==Introduction==
 
==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.
+
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, <b>mcc</b>, and run the compiled code as regular jobs without further license check (see site specific section below for details).
  
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.
+
==MATLAB on Graham==
 +
MATLAB 2017a is available on Graham with modules. However, neither does SHARCNET nor Compute Canada hold a licence for users. Users need to have access to a valid licence in order run Matlab on Graham. Users may run Matlab on Graham using their campus site license subject to the agreement by the site license management at their home institutions. Please check the info at [[https://docs.computecanada.ca/wiki/MATLAB CC MATLAB]] and submit a ticket at help@sharcnet.ca for details.
  
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, <b>mcc</b>, and run the compiled code as regular jobs without further license check (see site specific section below for details).
+
To use matlab 2017a on Graham:
 +
module load matlab/2017a
  
==SHARCNET MATLAB PCT License==
+
Several Matlab compiler runtime (MCR) versions are installed on Graham as well. User can run compiled (using mcc) Matlab code on Graham without license restriction. Please check the available version using 'module avail' command on the system.
===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.  
+
===Job Submission===
 +
Graham uses Slurm scheduler, which is different from the sq command used on other Sharcnet clusters.
  
*We only grant access to those who can provide reasonable performance results.
+
The following is a job script, Matlab_job.sh, to run single MATLAB job using the Slurm job scheduler:
 +
#!/bin/bash
 +
#SBATCH --ntasks=1                # number of tasks
 +
#SBATCH --cpus-per-task=1        # number of cores per task (adjust this when using PCT)
 +
#SBATCH --mem-per-cpu=2096M      # memory; default unit is megabytes
 +
#SBATCH --time=0-00:20            # time (DD-HH:MM)
 +
#SBATCH --input=matlab_test.m    # input file
 +
#SBATCH --output=matlab_test.log  # output file
 +
module load matlab/2017a
 +
srun matlab -nodisplay -nosplash -nojvm -singleCompThread
  
*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.
+
Change the script to be an executable file, then submit the job from the input file directory with
 +
sbatch matlab_job.sh
  
===Configuration and Examples===
+
For slurm scheduler on Graham, see [https://docs.computecanada.ca/wiki/Running_jobs Running Jobs]
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 
+
[https://www.sharcnet.ca/help/index.php/Using_MATLAB Using SHARCNET MATLAB PCT].
+
  
 
==Western University Site License==
 
==Western University Site License==
Users from Western are covered under the [http://www.uwo.ca/its/sitelicense/matlab/index.html 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 [mailto:help@sharcnet.ca contacting us] prior to every Thursday noon, so that their usernames can be registered by ITS on Friday.
+
Users from Western are covered under the [http://www.uwo.ca/its/sitelicense/matlab/index.html 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 [mailto:help@sharcnet.ca contact us] prior to every Thursday noon, so that their usernames can be registered by [http://wts.uwo.ca/ WTS] on Friday.
 
+
Using MATLAB is restricted to <b>goblin</b> and <b>kraken</b>'s <b>bull</b> nodes.  
+
  
 
===Version Selection===
 
===Version Selection===
 +
 
To use MATLAB, first load the module
 
To use MATLAB, first load the module
 +
 
  module load matlab
 
  module load matlab
  
 
===Job Submission===
 
===Job Submission===
 +
 +
On '''graham''' and '''cedar''', one needs to write a shell script for submitting jobs. Please refer to the Compute Canada [https://docs.computecanada.ca/wiki/MATLAB wiki] for details.
 +
 
Interactive job is discouraged. To run a MATLAB job, you must use <b>sqsub</b> command, with option -i <i>matlab_script</i>, e.g.
 
Interactive job is discouraged. To run a MATLAB job, you must use <b>sqsub</b> command, with option -i <i>matlab_script</i>, e.g.
 +
 
  sqsub -q serial -r 1h -o my_matlab.out -i my_matlab_code.m matlab
 
  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===
 
===Using Multicores===
Line 45: Line 56:
 
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
 
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:
+
On goblin and dusky:
  
 
  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
 
  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.
 
Note, for running multicores, one needs to use the absolute path with the three options shown above.
Line 72: Line 79:
  
 
===Help===
 
===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 [http://www.uwo.ca/its/sitelicense/matlab/index.html ITS's web site].
+
Western users who want to run MATLAB on SHARCNET systems must have access to a valid licence. To use the Western site licence, one must make a request through SHARCNET ticket system (or email to help@sharcnet.ca) before Thursday noon.
  
*If you see a license error, please open a ticket on the SHARCNET webportal [https://www.sharcnet.ca/my/problems/submit submit ticket] or contact the [mailto:bge@sharcnet.ca local staff] for immediate attention.
+
If you see a license error, please open a ticket on the SHARCNET webportal [https://www.sharcnet.ca/my/problems/submit submit ticket] or contact the [mailto:bge@sharcnet.ca local staff] for immediate attention.
  
 
==University of Waterloo Site License==
 
==University of Waterloo Site License==
 
Users in UW who have access to UW MATLAB site license [http://ist.uwaterloo.ca/admin/matlabnoform.html UW_IST] can run standard MATLAB on orca, saw, mosaic.  
 
Users in UW who have access to UW MATLAB site license [http://ist.uwaterloo.ca/admin/matlabnoform.html UW_IST] can run standard MATLAB on orca, saw, mosaic.  
 +
 +
<span style="color:#FF0000">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 </span>.
  
 
===Version Selection===
 
===Version Selection===
UW MATLAB 2014a and 2012b are available on orca and mosaic, user side PATH setting is not needed.
+
UW MATLAB R2016b, R2015b, R2014a and R2012b are available on orca, mosaic and saw, user side PATH setting is not needed.
  
 
===Job Submission===
 
===Job Submission===
 +
====submit a job to the scheduler using sqsub====
 
*Prepare a job directory for matlab, i.e., /work/yourid/matlab.
 
*Prepare a job directory for matlab, i.e., /work/yourid/matlab.
  
Line 90: Line 100:
 
  cp ~jemmyhu/Matlab/matlab_test.m .
 
  cp ~jemmyhu/Matlab/matlab_test.m .
  
*Using 'sqsub' to submit the job into the default serial queue
+
*Using 'sqsub' to submit the job into the default serial queue, use 3GB memory for example
  sqsub -r 1.0d -o matlab_test.log -i matlab_test.m ./uwmatlab
+
  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.,
+
the runscript 'uwmatlab' is simply one line command to run batch job on the cluster, i.e., for R2016b:
  /opt/sharcnet/local/matlab/R2014a/bin/matlab -nodisplay -nosplash -nojvm -singleCompThread
+
  /opt/sharcnet/local/matlab/R2016b/bin/matlab -nodisplay -nosplash -nojvm -singleCompThread
  
 
A few simple examples can be found in
 
A few simple examples can be found in
 
  /home/jemmyhu/matlab/
 
  /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===
 
===General Notes===
Line 102: Line 148:
 
The steps to use 'mcc' and run serial farming MATLAB jobs for UW site license on orca are<br>
 
The steps to use 'mcc' and run serial farming MATLAB jobs for UW site license on orca are<br>
 
*Set up the environments by adding the following two lines to your .bash_profile file, e.g., for R2014a
 
*Set up the environments by adding the following two lines to your .bash_profile file, e.g., for R2014a
 +
module load matlab/R2014a.mcr
 
  export PATH=/opt/sharcnet/local/matlab/R2014a/bin:$PATH
 
  export PATH=/opt/sharcnet/local/matlab/R2014a/bin:$PATH
 
  export LD_LIBRARY_PATH=/opt/sharcnet/local/matlab/R2014a/runtime/glnxa64/:${LD_LIBRARY_PATH}
 
  export LD_LIBRARY_PATH=/opt/sharcnet/local/matlab/R2014a/runtime/glnxa64/:${LD_LIBRARY_PATH}
Line 114: Line 161:
  
 
*Run <tt>myprog</tt> as a standard serial job using sqsub from login node, using 3GB memory.  
 
*Run <tt>myprog</tt> 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]
+
  sqsub --mpp=3g -r 1.0h -o run_myprog.log ./run_myprog.sh $mcrroot [arguments]
  
 
====Helps====
 
====Helps====
Line 120: Line 167:
  
 
==McMaster University Site Licence==
 
==McMaster University Site Licence==
For McMaster users who have contributed to the campus license pool, MATLAB is available on Wobbie, Iqaluk and Requin.  
+
For McMaster users who have contributed to the campus license pool, MATLAB is available on Wobbie, Iqaluk and Orca and Graham.  
  
 
===Version Selection===
 
===Version Selection===
Line 148: Line 195:
 
*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 [https://www.sharcnet.ca/my/problems/submit submit ticket] or email hahn@sharcnet.ca to get it fixed.
 
*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 [https://www.sharcnet.ca/my/problems/submit submit ticket] or email hahn@sharcnet.ca to get it fixed.
  
==MATLAB for no-site license users==
+
==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
 
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)===
 
=== MATLAB Compiler Runtime (MCR)===
Line 160: Line 207:
 
2) copy the files generated by mcc to SHARCNET, e.g., your /work directory on SHARCNET cluster
 
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
+
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/R2012b.mcr
+
  module load matlab/R2014a.mcr
 
exit and login again to effect the change.
 
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
+
4) submit 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]
 
  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 ===
 
=== Use Octave ===
Line 192: Line 236:
 
o Submit Matlab Jobs to Sharcnet using Desktop Client<br>
 
o Submit Matlab Jobs to Sharcnet using Desktop Client<br>
 
https://www.sharcnet.ca/help/index.php/Using_MATLAB
 
https://www.sharcnet.ca/help/index.php/Using_MATLAB
 +
 +
o Compute Canada MATLAB Page<br>
 +
https://docs.computecanada.ca/wiki/MATLAB

Latest revision as of 13:19, 2 August 2019

This page is scheduled for deletion because it is either redundant with information available on the CC wiki, or the software is no longer supported.
MATLAB
Description: MATLAB
SHARCNET Package information: see MATLAB software page in web portal
Full list of SHARCNET supported software


Introduction

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).

MATLAB on Graham

MATLAB 2017a is available on Graham with modules. However, neither does SHARCNET nor Compute Canada hold a licence for users. Users need to have access to a valid licence in order run Matlab on Graham. Users may run Matlab on Graham using their campus site license subject to the agreement by the site license management at their home institutions. Please check the info at [CC MATLAB] and submit a ticket at help@sharcnet.ca for details.

To use matlab 2017a on Graham:

module load matlab/2017a

Several Matlab compiler runtime (MCR) versions are installed on Graham as well. User can run compiled (using mcc) Matlab code on Graham without license restriction. Please check the available version using 'module avail' command on the system.

Job Submission

Graham uses Slurm scheduler, which is different from the sq command used on other Sharcnet clusters.

The following is a job script, Matlab_job.sh, to run single MATLAB job using the Slurm job scheduler:

#!/bin/bash 
#SBATCH --ntasks=1                # number of tasks
#SBATCH --cpus-per-task=1         # number of cores per task (adjust this when using PCT)
#SBATCH --mem-per-cpu=2096M       # memory; default unit is megabytes 
#SBATCH --time=0-00:20            # time (DD-HH:MM) 
#SBATCH --input=matlab_test.m     # input file
#SBATCH --output=matlab_test.log  # output file
module load matlab/2017a 
srun matlab -nodisplay -nosplash -nojvm -singleCompThread

Change the script to be an executable file, then submit the job from the input file directory with

sbatch matlab_job.sh

For slurm scheduler on Graham, see Running Jobs

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 contact us prior to every Thursday noon, so that their usernames can be registered by WTS on Friday.

Version Selection

To use MATLAB, first load the module

module load matlab

Job Submission

On graham and cedar, one needs to write a shell script for submitting jobs. Please refer to the Compute Canada wiki for details.

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

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 and dusky:

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

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

Western users who want to run MATLAB on SHARCNET systems must have access to a valid licence. To use the Western site licence, one must make a request through SHARCNET ticket system (or email to help@sharcnet.ca) before Thursday noon.

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 R2016b:

/opt/sharcnet/local/matlab/R2016b/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 matlab/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 Orca and Graham.

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) submit 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 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

o Compute Canada MATLAB Page
https://docs.computecanada.ca/wiki/MATLAB