MATLAB: How to determine the amount of available memory on a given worker on a cluster using Parallel Computing Toolbox 4.1 (R2009a)

admincenterclusterMATLAB Parallel ServermemoryParallel Computing Toolboxpctworker

I am attempting to execute MATLAB code on a cluster of computers using the Parallel Computing Toolbox 4.1 (R2009a). My cluster is a hybrid cluster consisting of Windows and Linux systems. I would like to obtain information about the amount of physical memory available on the systems hosting workers. Additionally, I would like to obtain information about the memory available to each worker.

Best Answer

The ability to obtain information about the available memory on each worker using the "Admin Center" utility or the "Configurations Manager" is not available in Parallel Computing Toolbox.
As a workaround, you can use the following code snippets to obtain this information. Use the workaround that best fits your need:
1. If you want information about the available statically i.e. before submitting a job or after a job has been run, you can create a job that queries for memory information and execute it on all workers that are part of the cluster. The code snippet below indicates how this can be done:
sched = findResource('scheduler', 'configuration', 'dinesh_jm');
myJob = createParallelJob(sched);
set(myJob, 'MinimumNumberOfWorkers', sched.ClusterSize);
set(myJob, 'FileDependencies', {'memoryCheck.m'});
myTask = createTask(myJob, @memoryCheck, 2, {});
submit(myJob);
wait(myJob);
allTasks = get(myJob, 'tasks');
memoryInfo = get(allTasks, 'OutputArguments');
workerInfo = get(allTasks, 'Worker');
where the function "memoryCheck" is defined as below:
function [result1 result2] = memoryCheck()
if ispc
[result1 result2] = memory;
else
[result1 result2] = system('free');
end
2. To obtain memory information, as the tasks are being executed, include the call to the function "memoryCheck" in the function that is being executed as part of the task periodically. The results returned by the function can be written to a text file which can be inspected to obtain the memory usage trend.