empty sparse matrix with size greater than (100000,100000) needs overhead space
이전 댓글 표시
For an industry project we want to set up a lookup-table from many (15) inputs to one output. The input values can be only in a small range, depending on each other, but may stretch over a great range otherwise, with at least 100 steps needed for resolution (-> 1e30 values). So I advised for sparse matrices.
Of course I may only use 2d-matrices, but that can be solved quite easily by re-indexing.
Nevertheless, I run into "Out-of-memory errors". The reason seems to be overhead memory that is needed to build empty sparse matrices with a size greater than (100000,100000) (-> 1e10 values). This overhead memory is only a fraction of the memory the full matrix would need of course, and this fraction grows less with the size of the matrix. But the absolute value grows with the size, up to the Out-of-memory error.
Why does a sparse matrix need any extra space at all? And why does it not need this space for relatively small sizes? Is it a bug? Is there a workaround?
clear
close all
[uV sV] = memory;
basemem = uV.MemUsedMATLAB;
try
for i = 1:20
A = sparse(10^i,10^i);
[uV sV] = memory;
mem(i) = uV.MemUsedMATLAB - basemem;
end
catch
dummy = 4;
end
l = numel(mem);
ls = 1;
addrSpace = 10.^((ls:l)*2);
figure
loglog(addrSpace,mem(ls:l));
figure
semilogx(addrSpace,mem(ls:l)./addrSpace);
clear
채택된 답변
추가 답변 (5개)
Mark Shore
2012년 2월 17일
for i = 1:20
A = sparse(10^i,10^i);
etc.
end
It seems that you are being a little optimistic in trying to create a (1E20,1E20) matrix, sparse or not.
Jochen Schuettler
2012년 2월 15일
0 개 추천
댓글 수: 1
James Tursa
2012년 2월 15일
How about multiple sparse column vectors contained in a cell array, each one that is within the limits of MAXSIZE. Complicates your indexing scheme, but seems like it could be done.
Sean de Wolski
2012년 2월 15일
0 개 추천
You could feed sparse an nzmax to help cut down on memory.
Jochen Schuettler
2012년 2월 16일
0 개 추천
댓글 수: 1
James Tursa
2012년 2월 16일
Can you show the exact code you are using to build the cell array of sparse matrices that is running out of memory?
Vanny moor
2012년 2월 17일
0 개 추천
Is there a way to only keep part of the matrix in memory at given time and the rest buffered on disk?
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!