0

I'm trying to use batch to simply run 5 parallel instances of a script. As a test I tried this:

for ii = 1:5
  jj{ii} = batch('magic(5000)');
end
wait(jj{5});

This appears to work, however I get a big nasty warning at each of the 5 times through. It's on a non-networked machine, but the headline is:

"Warning: Objects of class 'parallel.job.CJSIndependentJob' cannot be saved to MAT files."

This error is actually repeated 4 times per loop iteration.

Any ideas what the problem is here? I'm not intending to save anything to disk.

1

1 Answer 1

1

The warning appears because by default when the batch command is used to invoke a script (or a string, as here), it captures the entire workspace and sends it to the workers so that they can use it for their computations. This lets you do stuff like this:

x = 100;
j = batch('size(x)')

and have it work.

In your case, you have two options - you can specify the 'Workspace' option to batch, like so:

j{ii} = batch('magic(1000)', 'Workspace', struct());

or, you could use a function:

j{ii} = batch(@magic, 1, {1000}); % 1 is number of outputs requested
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.