9

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

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

Update 1

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);

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();

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.

15
  • 2
    distcomp errors are mainly related due to a bug from MATLAB when using more recent versions of Java with regards to the Parallel Computing Toolbox. Check my post here: stackoverflow.com/questions/24564988/… . Also, which Java version are you using? Any Java versions higher than 1.6.0_39 will make the toolbox wonky. Try patching your version of MATLAB using the instructions found in my post. To check your Java version, go into the command prompt / terminal and type in java -version.
    – rayryeng
    Jul 6, 2014 at 6:49
  • @rayryeng java version "1.7.0_25". The thing is I am running on school's HPC. Hence, I cannot fix the patch following your solution because I am not the administrator. Plus, please kindly see my updated question. The updated snippet runs without any error under exactly the same settings on the same HPC. Hence, I think there may be some subtle differences between these two snippets, which causes one to succeed, the other to fail. Jul 6, 2014 at 15:09
  • The only difference I can see is that you are calling two different functions in the if condition between both codes. Can you tell us/me what the functions are doing? Maybe there is something in each function that is causing the PCT to fail in compute_displacement.
    – rayryeng
    Jul 6, 2014 at 18:41
  • @rayryeng Both of them call a scientific software to compute the results. I have tested both functions, and they all return correct numeric results. So that block can be considered correct, since anyways they all return values to MATLAB, which has been verified. The difference may be one returns one number, and the other returns two? But does that matter? Jul 6, 2014 at 19:39
  • 1
    @rayryeng Yes, they should be able to help in such a case. Thanks a lot, man. Will update you when this is solved. ;) Jul 7, 2014 at 13:58

2 Answers 2

1

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.

0

After working a while on my own similar code block, I've decided that this is actually a memory issue.

I'm using a 6 core 4GHz CPU and 8 gigs of RAM and seen this issue (on MATLAB 2014b) when I set the worker count high, and did not have any problems with low worker counts.

When I use 6 or more workers (which is not ideal I know), memory consumption is high and this error message pops out sporadically. Also I have seen various out of memory errors in my tests.

I havent seen the error when I use 5 or less workers thus far, and I'm pretty sure some memory limit (possibly inside a java code block) is causing this issue by preventing some of the results' integrity (or existance)

Hope you can resolve this issue by reducing the worker count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.