Error using fetchnext and parallel.pool.constant

11 次查看(过去 30 天)
I have this code, that I run on a remote cluster. I followed this tutorial on using parallel.pool.constant with parfeval. I run into a problem in fetchnext. The error is "Error using parallel.FevalFuture/fetchNext . The function evaluation completed with an error. Caused by no workers abailable for FevalQueue excution". I followed this as well. An error occured during parallel.pool.constant . I am not sure how to proceed.
poolobj=parpool('my_cluster',8);
[up, op]=ndgri(1e-3:1e-2:1,1e-3:1e-2:1);
up=reshape(up, [1,size(up,1)*size(up,2)]);
up=reshape(up, [1,size(up,1)*size(up,2)]);
z=rand(5,5e3);
addAttachedFiles('<path to my function/cores_random.m');%%to add the function files to workers on the pool
C1=parallel.pool.Constant(z);%%use parallel.pool.Constant to copy these variables into workers
U2=parallel.pool.Constant(up);
O2=parallel.pool.Constant(op);
for i=1:size(up,2)
f1(i) = parfeval(poolobj,@cores_random, 3, i, 1,C1,U2,O2); %%line 11
f2(i) = parfeval(poolobj,@cores_random, 3, i, 2,C1,U2,O2);
f3(i) = parfeval(poolobj,@cores_random, 3, i, 3,C1,U2,O2);
f4(i) = parfeval(poolobj,@cores_random, 3, i, 4,C1,U2,O2);
f5(i) = parfeval(poolobj,@cores_random, 3, i, 5,C1,U2,O2);
end
wait(f1);
wait(f2);
wait(f3);
wait(f4);
wait(f5);
for j=1:size(up,2):-1:1
[idx1,u1,o1,ep1]=fetchNext(f1);
[idx2,u2,o2,ep2]=fetchNext(f2);
[idx3,u3,o3,ep3]=fetchNext(f3);
[idx4,u4,o4,ep4]=fetchNext(f4);
[idx5,u5,o5,ep5]=fetchNext(f5);
end
function [uu,oo,ep] = cores_random(i, zidx,C1,U2,O2)
up = U2.Value(i)
op = O2.Value(i);
z = C1.Value(zidx,:);
%%doing some calculations here
%%z is of size 1*1e3
%%up is scalar op is scalar
end
  3 个评论
Muna Tageldin
Muna Tageldin 2020-10-22
yes sorry I made a typo. Actually its 3 in the real code. This is a simplified code.
Muna Tageldin
Muna Tageldin 2020-10-22
so basically, I should write 4 for outputs ? ( three from the function and one index)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Asynchronous Parallel Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by