Call library with parfor

2 次查看(过去 30 天)
arnaud ensberg
arnaud ensberg 2016-1-28
评论: Bernie St 2017-8-24
I use javaplex it's a library, with for i can use it without any error:
for i=1:size(mat,1)
max_dimension = 3;
max_filtration_value = 1000;
num_divisions = 10000;
%options.max_filtration_value = max_filtration_value;
%options.max_dimension = max_dimension - 1;
% fprintf('on est à l indice %d\n', i);
maColonne = mat(i,:); %cela va mettre ta i_ème colonne dans la variable maColonne
matricepos = vec2mat(maColonne,3);
point_cloud=matricepos;
stream = api.Plex4.createVietorisRipsStream(point_cloud, max_dimension, max_filtration_value, um_divisions);
end
but when i use the same code with parfor, i have this error :
Error: MATLAB cannot determine whether "api" refers to a function or variable.
See Parallel for Loops in MATLAB, "Unambiguous Variable Names".
parfor i=1:size(mat,1)
max_dimension = 3;
max_filtration_value = 1000;
num_divisions = 10000;
%options.max_filtration_value = max_filtration_value;
%options.max_dimension = max_dimension - 1;
% fprintf('on est à l indice %d\n', i);
maColonne = mat(i,:); %cela va mettre ta i_ème colonne dans la variable maColonne
matricepos = vec2mat(maColonne,3);
point_cloud=matricepos;
stream = api.Plex4.createVietorisRipsStream(point_cloud, max_dimension, max_filtration_value, num_divisions);
end
the error comme from this line:
stream = api.Plex4.createVietorisRipsStream(point_cloud, max_dimension, max_filtration_value, num_divisions);
how can i call a function form library on parfor
please
  3 个评论
Edric Ellis
Edric Ellis 2016-1-29
Are you calling javaaddpath on the client? If so, you'll need to call javaaddpath on the workers. Something like this perhaps:
spmd
javaaddpath('path/to/javaplex');
end
Bernie St
Bernie St 2017-8-24
Hi Arnaud, did you manage to solve this problem? I am trying to use javaplex in parfor loops and have the exact same error message. Unfortunately both adding the java path in the parfor loops as well as importing within the loop did not solve the problem for me.

请先登录,再进行评论。

回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by