我目前在Matlab中工作,这是我第一次尝试并行处理。我的代码运行得很好,直到我在代码的顶部添加了matlabpool('open',4);,在底部添加了matlabpool('close');。
如果我加上这两行,我所有的CPU-Cores都是100%的工作负载(就像预期的那样),并且我的代码仍然可以工作,除了我在parfor循环中实现的waitbar。
代码看起来像这样:
matlabpool('open',4);
global bar;
bar = waitbar(0, 'Waitbar');
parfor i=1:1000
//working code
try
waitbar(UPDATED_VALUE, bar, UPDATED_STRING);
end
end
try
close(bar);
end
//display results
matlabpool('close');我得到的错误如下:
Warning: This functionality is no longer supported under the -nodisplay and -noFigureWindows startup options. For more information, see "Changes to -nodisplay and -noFigureWindows Startup Options" in the MATLAB Release Notes. To view the release note in your system browser, run web('http://www.mathworks.com/access/helpdesk/help/techdoc/rn/br5ktrh-1.html#br5ktrh-3', '-browser')
In uitools\private\warnfiguredialog at 26
In waitbar at 38
In montecarlo>(parfor body) at 41
In parallel_function>make_general_channel/channel_general at 891
In remoteParallelFunction at 28 我真的不知道我做错了什么。有人能帮帮我吗?
发布于 2014-11-18 22:36:33
我认为你所做的“错误”是在parfor循环中使用了一个waitbar,哈哈。但说真的,我担心这是因为迭代在parfor循环中不是按顺序执行的,因此禁止使用常规的waitbar,因为Matlab客户端和执行该循环的工作者之间共享信息的方式。即使您没有编写matlabpool('open',4),MATLAB也会打开它,所以问题实际上是waitbar在parfor循环中。
作为一种解决方法,您可能希望查看文件交换表单中的this提交。它是由在Mathworks工作的Edric Ellis写的,所以我会信任他的程序:)
希望这能有所帮助!
https://stackoverflow.com/questions/26996526
复制相似问题