Pre-calculating memory usage of repmat.m to avoid out of memory errors
3 ビュー (過去 30 日間)
古いコメントを表示
A and B are equal length vectors of my data. The max value in A is 100 and the max value in B is 20,000 and n = 2,500. I wish to run the following code
n = length(A); % length(A) == length(B);
a = 1; b =1;
gridx1 = [1 : a : max(ceil(A))];
gridx2 = [1 : b : max(ceil(B))];
[gridx2,gridx1] = meshgrid(gridx2,gridx1);
x1 = repmat(gridx1, [1,1,n]);
x2 = repmat(gridx2, [1,1,n]);
mu1 = repmat(A,[length(gridx1),length(gridx2),1]);
mu2 = repmat(B,[length(gridx1),length(gridx2),1]);
However I get an out of memory error. Hence I need to reduce the sampling frequency of the grids.
Lets say I wish to allocate up to 3GB of RAM to this process, how can I find the sampling frequency, "a" and "b".
Obviously I wish to sample at the maximum frequency possible (subject to the 3GB constraint) to get the most accurate answer.
thank you
2 件のコメント
Jan
2013 年 2 月 7 日
Isn't this a simple division? Do 3GB belong to one oy the arrays e.g. mu2, or is it the sum of all defined arrays?
Jason Ross
2013 年 2 月 7 日
編集済み: Jason Ross
2013 年 2 月 7 日
I'll state what I hope is pretty obvious: If you are regularly hitting "Out of memory" issues, you really should move to a 64-bit operating system. The hardware and operating systems have supported it for years now. Barring a few specialized use cases (generally related to hardware drivers), there is no downside to moving to a 64-bit operating system. RAM is also quite inexpensive, 16 GB can be had for less than $100, 24 GB less than $150, 32 GB less than $200 and even 64 GB is running ~$350. This, of course, assumes a desktop host with a motherboard that can take these types of chips.
採用された回答
その他の回答 (1 件)
cr
2013 年 2 月 7 日
編集済み: cr
2013 年 2 月 7 日
say, Lg1 is length(gridx1) and Lg2 is length(gridx2). Then your variables need this much memory x1: Lg1*Lg2*n*8 bytes (assuming you are using doubles), x2: Lg1*Lg2*n*8 bytes This is where the problem lies. Other not so big. Use singles or integer types if doubles are not necessary. Or, do your operations sequentially clearing intermediate variables.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!