\\
**[[cluster:0|Home]]**
==== Note ====
You can also run matlab jobs via scripts like other software.
Create a file with the matlab commands and then create a shell script to submit the job.
It would look like
#!/bin/bash
# submit via 'bsub < run.serial'
#BSUB -q matlab
#BSUB -J test
#BSUB -o test.stdout
#BSUB -e test.stderr
matlab -no display < my_code.m > /dev/null
==== Matlab 2013a ====
Is now the default matlab version, just change the paths in scripts below
--- //[[hmeij@wesleyan.edu|Meij, Henk]] 2013/03/14 14:57//
==== Matlab 2010b ====
So, now that 2010b is the version of Matlab and we're using Lava scheduler we need to integrate the two.
* [[http://www.mathworks.com/support/solutions/en/data/1-4SUZLX/?solution=1-4SUZLX|How can I integrate MATLAB Distributed Computing Server with the Lava scheduler?]]
* [[http://www.mathworks.com/products/distriben/supported/sched/|Scheduler Support in Parallel Computing Toolbox and MATLAB Distributed Computing Server]]
* [[http://www.mathworks.com/help/toolbox/distcomp/bqur7ev-35.html|Part 1]]
* [[http://www.mathworks.com/help/toolbox/distcomp/bqxceii-1.html|Part2]]
=== Serial 1 ===
In the example below, the code waits for the results. Don't do that when submitting jobs, it is just for debugging purposes.
This old way still works for distributed jobs:
% distributed matlab jobs
% start 'matlab -nodisplay', issue the command 'Simple'
% set up the scheduler and matlab worker environment
sched = findResource('scheduler', 'type', 'generic');
set(sched, 'HasSharedFilesystem', true);
set(sched, 'ClusterMatlabRoot', '/share/apps/matlab/2010b')
set(sched, 'SubmitFcn', @lsfSimpleSubmitFcn)
% specify location for worker output
set(sched, 'DataLocation', '/home/hmeij/hp/matlab')
% create job and assign tasks to be done
j = createJob(sched);
T = createTask(j, @rand, 1, {{3,3} {3,3} {3,3} {3,3} {3,3}});
% submit job, wait for jobs to finish, fetch output
submit(j)
% WARNING: this may hang if the workers are busy!
waitForState(j)
results = getAllOutputArguments(j);
results{1:5}
% better to do it like Simple2.m
=== Serial 2 ===
After you submit the job, you can exit matlab.
% distributed matlab jobs
% start 'matlab -nodisplay', issue the command 'Simple2'
% set up the scheduler and matlab worker environment
sched = findResource('scheduler', 'type', 'generic');
set(sched, 'HasSharedFilesystem', true);
set(sched, 'ClusterMatlabRoot', '/share/apps/matlab/2010b')
set(sched, 'SubmitFcn', @lsfSimpleSubmitFcn)
% specify location for worker output
set(sched, 'DataLocation', '/home/hmeij/hp/matlab')
% create job and assign tasks to be done
j = createJob(sched);
T = createTask(j, @rand, 1, {{3,3} {3,3} {3,3} {3,3} {3,3}});
% submit job, then exit matlab interactive session
submit(j)
get(sched)
=== Parallel ===
Slightly different syntax. Adjust your number of workers values based on some benchmarking, not always do the most workers finish a job in the shortest amount of time.
% parallel matlab jobs
% start 'matlab -nodisplay', issue the command 'Simplep'
% set up the scheduler and matlab worker environment
sched = findResource('scheduler', 'type', 'generic')
set(sched, 'HasSharedFilesystem', true);
set(sched, 'ClusterMatlabRoot', '/share/apps/matlab/2010b')
set(sched, 'ParallelSubmitFcn', @lsfParallelSubmitFcn)
% specify location for worker output
set(sched, 'DataLocation', '/home/hmeij/hp/matlab')
pj = createParallelJob(sched);
set(pj, 'MaximumNumberOfWorkers', 8)
set(pj, 'MinimumNumberOfWorkers', 8)
T = createTask(pj, @rand, 1, {{300,300}});
% submit job, wait to finish, get status jobs, gather results
submit(pj)
get(sched)
% you can now exit matlab
% at system prompt type 'bjobs'
\\
**[[cluster:0|Home]]**