Large Matrix multiplication and out of memory error in matlab
Ältere Kommentare anzeigen
i have sparse matrix V of size V =<162000x32400 double> or even bigger , I have to solve the following equations.
x_0=ones(size(V ,1) ,1);
y_0=V'*x_0;
result=V'*V + y_0*y_0'; %%%%%Problem here
The problem is in right hand side of last equation and is giving me out of memory error.
Akzeptierte Antwort
Weitere Antworten (4)
Walter Roberson
am 31 Okt. 2011
0 Stimmen
Is y_0=V'*x_0; the same as sum(V) ?
1 Kommentar
imran khan
am 31 Okt. 2011
Jan
am 31 Okt. 2011
0 Stimmen
A [162000x32400] DOUBLE array needs 42GB memory. I'm not sure if computing V'*V + y_0*y_0' needs to allocate one, two or three further blocks of this size as temporary memory. In every case the blocks must be available in contiguos blocks. Therefore I estimate you need 128 to 256 GB free RAM.
How many RAM do you have installed?
(Is V sparse?) [EDITED:] How sparse is V?
3 Kommentare
Walter Roberson
am 31 Okt. 2011
The problem statement does start by saying V is sparse.
imran khan
am 31 Okt. 2011
imran khan
am 1 Nov. 2011
Titus Edelhofer
am 31 Okt. 2011
0 Stimmen
Hi Imran,
I guess the problem is, that y_0*y0' most likely will be a full matrix, as long as your V matrix has no columns that sum up to zero. This will fail already as Jan pointed out. You might get along by looping over the columns of your matrix V ...
Titus
1 Kommentar
imran khan
am 1 Nov. 2011
Titus Edelhofer
am 1 Nov. 2011
Hi Imran,
something like the following should work:
n = size(V,2);
blksize = 100;
result = zeros(n);
for i=0:(blksize-1)
columns = i*n/blksize + (1:n/blksize);
result(:, columns) = V'*V(:,columns) + y_0*y_0(columns)';
end
I must admit I did not check if it is really correct, but should give an impression (and can be verified easily on small example). The blksize can be experimented for balancing memory and speed.
Titus
3 Kommentare
imran khan
am 3 Nov. 2011
Titus Edelhofer
am 3 Nov. 2011
Hi Imran,
I updated the code (n needs to be the number of columns). by the way, the code assumes, that the number of columns of V is a multiple of the blksize, otherwise one needs to be more careful ...
Titus
imran khan
am 4 Nov. 2011
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!