0

I am trying to compute the eigenvalues of a big matrix on matlab using the parallel toolbox. I first tried:

 A = rand(10000,2000);
A = A*A';
matlabpool open 2
spmd
    C = codistributed(A);
    tic
    [V,D] = eig(C);
    time = gop(@max, toc) % Time for all labs in the pool to complete.  
end
matlabpool close

The code starts its execution:

Starting matlabpool using the 'local' profile ... connected to 2 labs.

But, after few minutes, I got the following error:

Error using distcompserialize
Out of Memory during serialization

Error in spmdlang.RemoteSpmdExecutor/initiateComputation (line 82)
                fcns  = distcompMakeByteBufferHandle( ...

Error in spmdlang.spmd_feval_impl (line 14)
    blockExecutor.initiateComputation();

Error in spmd_feval (line 8)
        spmdlang.spmd_feval_impl( varargin{:} );

I then tried to apply what I saw on tutorial videos from the parallel toolbox:

>> job = createParallelJob('configuration', 'local');
>> task = createTask(job, @eig, 1, {A});
>> submit(job);
waitForState(job, 'finished');
>> results = getAllOutputArguments(job)
>> destroy(job);

But after two hours computation, I got:

results = 

   Empty cell array: 2-by-0

My computer has 2 Gi memory and intel duoCPU (2*2Ghz)

My questions are the following: 1/ Looking at the first error, I guess my memory is not sufficient for this problem. Is there a way I can divide the input data so that my computer can handle this matrix? 2/ Why is the second result I get empty? (after 2 hours computation...)

EDIT: @pm89

You were right, an error occurred during the execution:

job =

Parallel Job ID 3 Information
=============================

              UserName : bigTree
                 State : finished
            SubmitTime : Sun Jul 14 19:20:01 CEST 2013
             StartTime : Sun Jul 14 19:20:22 CEST 2013
      Running Duration : 0 days 0h 3m 16s

- Data Dependencies

      FileDependencies : {}
      PathDependencies : {}

- Associated Task(s)

       Number Pending  : 0
       Number Running  : 0
       Number Finished : 2
      TaskID of errors : [1  2]

- Scheduler Dependent (Parallel Job)

MaximumNumberOfWorkers : 2
MinimumNumberOfWorkers : 1
bigTree
  • 2,103
  • 6
  • 29
  • 45
  • 1
    About the *Out of Memory* error, see [Resolving "Out of Memory" Errors](http://www.mathworks.com/help/matlab/matlab_prog/resolving-out-of-memory-errors.html). About the second case, most probably the job has been terminated by an error. Before *destroying the job*, just type `job` in command window and see the job and its tasks status. – p8me Jul 14 '13 at 16:13
  • 1
    A trivial suggestion: try your code on smaller matrices, first! Your first example is correct but makes no or little sense on your machine. By default matlab will use multithreaded routines on multi core cpus; using `smpd` on 2 workers, one for each core, you will experience a slowdown with respect to the multithread (default) computation. Your second example will perform the same computation (i.e. `eig(A)`) on each core, so taking the double of the time required. – Stefano M Jul 14 '13 at 16:49
  • @StefanoM I actually did some tests on small matrices first. I am writing this code on large matrices because I need to process such matrices. Thank you for your answer, but it raises some questions to me: 1/ if matlab uses multithreaded routines by default, then what difference can be made using the parallel toolbox? 2/ For my second example, I should then divide my matrix first and compute the eigenvalues for each submatrix? – bigTree Jul 14 '13 at 17:11
  • 1
    1) The parallel toolbox is for explicit parallel code (as opposed to implicit, when multithreading is implemented in the linalg libraries.) Examples are data parallel computations, worker pools made from more than a single node, clusters. 2) Eigenvalue decomposition is not data parallel, (as opposed to matrix sum, for example), so you cannot trivially decompose the problem into smaller ones. You have to rely on matlabs `eig`. Have also a look on the GPU accelerated eig function, if you have a supported GPU card and enough video memory: `G = gpuArray(A); [V,D] = eig(G);` – Stefano M Jul 14 '13 at 18:49
  • 1
    If it helps your code works fine on my machine. So I guess you're running of memory in both cases. – p8me Jul 19 '13 at 01:27
  • @pm89: Just out of curiosity: is the GPU approach faster than the CPU version? – Beni Bogosel Dec 14 '15 at 10:53

0 Answers0