How to Use the Cluster (Matlab)

Submitting Matlab Jobs to Ocha

Introduction
This document discusses the necessary steps to get Matlab scripts and functions running on Loyola’s  Ocha cluster.  The Ocha cluster provides access to the four GPUs and up to thirty cores which can improve processing speed when tasks can be run in parallel.

System requirements
Ocha Matlab users must have access to a Matlab license with the parallel toolbox on a campus computer.  Note, you can access Ocha remotely by accessing your campus computer remotely through workspace.loyola.edu.    Your local Matlab installation must also have the same Matlab version that is currently installed on Ocha.
The current installation is 2016b.

Getting started using Matlab on Ocha
Necessary changes to your host file:
To get started connecting to Ocha through Matlab you must first edit the host file on your local machine.  Your host file can be found at: Windows/system32/drivers/etc/hosts.  You should first back up the host file by saving it in the same directory as another name.  Next, you must add the following line to the file:
144.126.12.153    master

To make this change you may need to contact OTS to gain administration rights to your machine.
Once you have made the necessary changes to your host file you will be able set up a cluster profile for Ocha in Matlab.  To do so follow these steps:

  1. From the parallel menu in Matlab select “Manage Cluster Profiles”
  2. Select add -> Custom -> then Matlab Job Scheduler
  3. Once the profile has been created select edit from the top menu.
  4. Enter a description for the cluster in the first field.
  5. For hostname enter cs.loyola.edu.
  6. The name of the MJS is optional, you can enter ochamjs.
  7. Click done.
  8. You can ensure that the setup has been done properly by clicking validate. The cluster profile should pass the first four tests, by not the fourth.  The parpool command is not available with the Ocha cluster for security reasons.

Useful Matlab Commands
Below is a list of useful Matlab functions to submit your jobs to Ocha:

  1. Parcluster: Allows you to set cluster to Ocha.
    Matlab Help:  https://www.mathworks.com/help/distcomp/parcluster.html?s_tid=gn_loc_drop
  2. Batch: Submits your job to Ocha.   Note that it is important to use the AttachedFiles or AutoAttachFiles options to send the necessary files from your local workstation to Ocha.
    Matlab Help https://www.mathworks.com/help/distcomp/batch.html?searchHighlight=batch&s_tid=doc_srchtitle
  3. createCommunicatingJob: Creates communication job to utilize multiple workers on the cluster.
    Matlab Help: https://www.mathworks.com/help/distcomp/createcommunicatingjob.html
  4. createTask: Adds a specific task to a job.
    Matlab Help: https://www.mathworks.com/help/distcomp/createtask.html?searchHighlight=createtask&s_tid=doc_srchtitle
  5. Diary: Displaying the Matlab Command diary.
    Matlab Help: https://www.mathworks.com/help/distcomp/diary.html?searchHighlight=diary&s_tid=doc_srchtitle
  6. Fetchoutputs: Captures the output of the job you run on Ocha.

Matlab Help:  https://www.mathworks.com/help/distcomp/fetchoutputs.html?searchHighlight=fetchoutputs&s_tid=doc_srchtitle

Example Code
Below is a quick example using the functions above.

c = parcluster(insert Ocha Cluster name here)
delete(c.Jobs)  %Clear existing cluster jobs
cjob = createCommunicatingJob(c,'Type','pool');
t = createTask(cjob, @clustertestparfor, 1,{3},'CaptureDiary', true)
submit(cjob)
wait(j)   % Wait for the job to finish
diary(j)  % Display the diary
r = fetchOutputs(cjob); % Get results into a cell array

The function clustertestparfor:

function [ A ] = clustertestparfor( x )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
tic
parfor j=1:10000
A(j,:)=x*rand(1,10000);
end
toc
end

For any questions on running your Matlab code on the cluster, please contact Jeremy Schwartz.