MATLAB parfor中的版本错误或endian-key吗? [英] Bad version or endian-key in MATLAB parfor?

查看:688
本文介绍了MATLAB parfor中的版本错误或endian-key吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MATALB parfor进行并行计算.代码结构看起来很像

I am doing parallel computations with MATALB parfor. The code structure looks pretty much like

%%% assess fitness %%%
% save communication overheads
bitmaps = pop(1, new_indi_idices);
porosities = pop(2, new_indi_idices);
mid_fitnesses = zeros(1, numel(new_indi_idices));
right_fitnesses = zeros(1, numel(new_indi_idices));
% parallelization starts
parfor idx = 1:numel(new_indi_idices) % only assess the necessary
    bitmap = bitmaps{idx};
    if porosities{idx}>POROSITY_MIN && porosities{idx}<POROSITY_MAX
        [mid_dsp, right_dsp] = compute_displacement(bitmap, ['1/' num2str(PIX_NO_PER_SIDE)]);
        mid_fitness = 100+mid_dsp;
        right_fitness = 100+right_dsp;
    else % porosity not even qualified
        mid_fitness = 0;
        right_fitness = 0;
    end
    mid_fitnesses(idx) = mid_fitness;
    right_fitnesses(idx) = right_fitness;
    fprintf('Done.\n');
    pause(0.01); % for break
end

我遇到了以下奇怪的错误.

I encountered the following weird error.

Error using parallel.internal.pool.deserialize (line 9)
Bad version or endian-key

Error in distcomp.remoteparfor/getCompleteIntervals (line 141)
                        origErr =
                        parallel.internal.pool.deserialize(intervalError);

Error in nsga2 (line 57)
    parfor idx = 1:numel(new_indi_idices) % only assess the necessary

我该如何解决?快速的Google搜索无法解决任何问题.

How should I fix it? A quick Google search returns no solution.

奇怪的是,以下代码段在完全相同的设置和相同的HPC下可以完美地工作.我认为两者之间可能存在一些细微的差异,从而导致其中一个起作用而另一个失败.工作片段:

The weirder thing is the following snippet works perfectly under the exactly same settings and the same HPC. I think there might be some subtle differences between them two, causing one to work and the other to fail. The working snippet:

%%% assess fitness %%%
% save communication overheads
bitmaps = pop(1, new_indi_idices);
porosities = pop(2, new_indi_idices);
fitnesses = zeros(1, numel(new_indi_idices));
% parallelization starts
parfor idx = 1:numel(new_indi_idices) % only assess the necessary
    bitmap = bitmaps{idx};
    if porosities{idx}>POROSITY_MIN && porosities{idx}<POROSITY_MAX
        displacement = compute_displacement(bitmap, ['1/' num2str(PIX_NO_PER_SIDE)]);
        fitness = 100+displacement;
    else % porosity not even qualified
        fitness = 0;
    end
    fitnesses(idx) = fitness;
    %fprintf('Done.\n', gen, idx);
    pause(0.01); % for break
end
pop(3, new_indi_idices) = num2cell(fitnesses);

更新2

怀疑[mid_dsp, right_dsp] = compute_displacement(bitmap, ['1/' num2str(PIX_NO_PER_SIDE)]);给我带来麻烦,我将其替换为

Update 2

Suspecting [mid_dsp, right_dsp] = compute_displacement(bitmap, ['1/' num2str(PIX_NO_PER_SIDE)]); causes me trouble, I replace it with

mid_dsp = rand();
right_dsp = rand();

然后,它起作用了!这证明这确实是由该特定线引起的.但是,我确实测试了该函数,并且它正确返回了两个数字!由于该函数像rand()一样返回值,所以看不到任何区别.这让我更加困惑.

Then, it works! This proves that this is indeed caused by this particular line. However, I do have tested the function, and it returns two numbers correctly! Since the function returns value just as rand() does, I can't see any difference. This confuses me more.

推荐答案

我遇到了同样的问题,结果是Matlab 2015为parfor中的每个循环保留了所有必要的内存资源,导致内存中断不足. 错误消息是棘手的.在循环中对代码进行微调并通过Windows 10中Pagefile中的系统设置从SSD提供120GB RAM之后,parfor可以漂亮地执行.

I had the same issue and it came out that Matlab 2015 is reserving all necessary memory resources for each of the loops in the parfor resulting in memory break shortage. The error message is tricky. After fine tuning the code in the loop and providing 120GB of RAM from the SSD through system setting in Pagefile in Windows 10, the parfor executed beautifully.

这篇关于MATLAB parfor中的版本错误或endian-key吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆