The University of York has licences for the MATLAB Parallel Computing Toolbox (PCT) and the MATLAB Distributed Computing Toolbox.  See this link for further information on the Parallel Computing Toolbox.  

Matlab parallel computing will allow you to submit your Matlab jobs (either through the Matlab GUI or via the command line) to Viking.  Instructions on how to do this will be described here.

NB.  It is best to run Matlab in your scratch directory on Viking since the output files can fill up the space on your home directory.  You can run it either through the matlab gui or on the command line. 

Before starting load the Matlab module.

module load math/MATLAB/2021a

Submitting Matlab workloads to Slurm using the Matlab GUI

With Matlab it is possible to submit jobs to Slurm using the Matlab gui.  We will describe below how to create a cluster profile and run your jobs using Slurm.

Creating a cluster profile.

If you prefer to use the Matlab gui, you can also create a cluster profile that can be reused.  

You can either create your own profile or use an existing one.  Instructions on how to create a profile can be found here.  Follow the guides for Slurm.

Adding an existing cluster profile

To add an existing cluster profile follow these steps. 

  1. Download the example profile (vikingprofile.mlsettings) and move it to the location where you will launch the Matlab GUI. 
  2. To access the cluster profile menu, select "Manage cluster profiles..." from the parallel option in the home tab.
  3. In the Cluster Profile Manager click on import and then select the file.  

Once the profile is loaded, you will need to edit some of the lin

  1. The folder where you will store the output of your jobs
  2. In the submit functions settings: adapt these to what you need and remember to change your project code.
  3. Memory is set at the minimum value for the JAVA engine to run Matlab

To use the profile,  you need to call it in your Matlab program.  Below is an example where slurm is used on Viking to submit the test_for.m code below.  If you wish to try with these scripts you will need to adapt the file paths accordingly.  You can also increase the number of tasks that can run at any one type using the NumWorkersRange values.  It is currently set to a max of 2.

c = parcluster ('vikingprofile');
myJob = createCommunicatingJob (c, 'Type', 'pool');
myJob.AttachedFiles = {'/users/abc123/scratch/matlabstorage/test/test_for.m'};
myJob.NumWorkersRange = [1 2];
task = createTask (myJob, @test_for, 1, {});
submit (myJob);
results = fetchOutputs(myJob);
logMess = getDebugLog (c, myJob);
function [elapsedTime] =  test_for()
N = 15000;
A = zeros(N,1);
for i=1:N
    E = eig(rand(100))+i;
A(i) = E(1);
elapsedTime = toc;

Once you have submitted your jobs to Viking , job progress can be viewed in two ways.  

Using the command line

squeue -u USERNAME

Using Matlab to monitor the jobs

Select Monitor Jobs option from parallel option in the home tab.  

Submitting Matlab jobs via the command line

You can also sumit jobs on the command line using the following

matlab -nosplash -nodesktop -nodisplay -r sgesubmitpar;exit
  • No labels