parFor Worker unable to find file. Unrecognized function or variable 'parameters'

25 views (last 30 days)
CSCh
CSCh on 13 Aug 2021
Commented: CSCh on 25 Aug 2021
Hi there I have trouble to paralize the the loop.
It is from here:
if I try to run the code below, parfor complains about the "iteration". If I set the iteration=epch, the the follwowing error occurs:
The source code ("XX".m) for the parfor-loop that is trying to execute on the worker could not be found.
Caused by:
Unrecognized function or variable 'parameters'.
Error using remoteParallelFunction (line 84)
Worker unable to find file.
Unrecognized function or variable 'parameters'.
But the "parameters" are defined-as you can see- inside the link above.
Any idea is welcome.!
Chris
start = tic;
iteration = 0;
parpool(32);
parfor epoch = 1:numEpochs
reset(mbq);
while hasdata(mbq)
iteration = iteration + 1;
dlXT = next(mbq);
dlX = dlXT(1,:);
dlT = dlXT(2,:);
% Evaluate the model gradients and loss using dlfeval and the
% modelGradients function.
[gradients,loss] = dlfeval(accfun,parameters,dlX,dlT,dlX0,dlT0,dlU0);
% Update learning rate.
learningRate = initialLearnRate / (1+decayRate*iteration);
% Update the network parameters using the adamupdate function.
[parameters,averageGrad,averageSqGrad] = adamupdate(parameters,gradients,averageGrad, ...
averageSqGrad,iteration,learningRate);
end
% Plot training progress.
loss = double(gather(extractdata(loss)));
addpoints(lineLoss,iteration, loss);
D = duration(0,0,toc(start),'Format','hh:mm:ss');
title("Epoch: " + epoch + ", Elapsed: " + string(D) + ", Loss: " + loss)
drawnow
end
  2 Comments
CSCh
CSCh on 13 Aug 2021
Thank you for your comment Edric,
If this loop is not parallelisable, are there any workarounds available?

Sign in to comment.

Answers (1)

Raymond Norris
Raymond Norris on 13 Aug 2021
As Edric mentioned, this is/may not parallizable. But if it were, you'd need to make modifications to the for-loop. You've included the updating of the figure within the parfor, which won't work as you're expecting (the pool of workers don't have access to your client MATLAB displaying the plot). There are ways around this, but won't address the fundemental issue of whether the loop can be parallelized.
I would suggest circling back to the Training Options section of the example, where it describes using GPUs to help train the model. I suspect this is where you find you best option to speed up the code.
  12 Comments

Sign in to comment.

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!