MATLAB: How to retrieve error message when running script on cluster
cluster error remote
Hi,
I am running batch jobs using MATLAB remotely on a cluster. How to view the eventual error messages(where I hope to find the line of code where the problem is)? Thanks in advance.
Best Answer
The task within the job object returned by thebatch command has a property calledError which has the error stack. You could do something like this:
job = batch('assert(false)');
wait(job);
getReport(job.Tasks(1).Error)
Also note that if you simply callload on thejob you'll see the error.
You can useparfeval on top of a parallel pool to do this. (Note that by opening a parallel pool of workers, you're actually reducing the number of workers available to runbatch jobs - workers can work oneither parallel pool things (parfor,parfeval, andspmd ),orbatch - but not both at the same time).
The programming interface toparfeval is broadly similar tobatch, so it should not be too difficult to adapt your code to use that instead.parfeval has the advantage of lower overheads once your parallel pool is set up (batch has to launch a new MATLAB worker process for each task that it executes).
Best Answer