필터 지우기
필터 지우기

How can I do a simple matrix multiplication withour running in any out of memory error

조회 수: 1 (최근 30일)
I want to multiply a big matrix (possibly 6000 * 6000) with its transpose. However I get out of memory error. I know that I don't have enough RAM to make this works...but is there any way I can get this to work?? I am running Matlab R2012b on 32bit windows vista. Can someone show me how to do this block wise, or some methods. The only thing that is important for me is that I need to use the result of the matrix multiplication for another analysis.
This is a sample of what I trying to do: A = ones(6000); B = A'*A; (I need to use B to get another code running).
Please advise, Thanks
  댓글 수: 2
per isakson
per isakson 2013년 5월 18일
편집: per isakson 2013년 5월 18일
R2012a, 64bit, Windows 7, old vanilla desktop, 8GB RAM.
>> tic, A = ones(6000); B = A'*A; toc
Elapsed time is 6.767988 seconds.
>> tic, A = rand(6000); B = A'*A; toc
Elapsed time is 7.429135 seconds.
I guess from looking at the Task Manager window that 4GB would have been enough so far.
>> tic, A = rand(9000); B = A'*A; toc
Elapsed time is 22.454364 seconds.
.
Try
doc memory
Iain
Iain 2013년 5월 22일
You can reduce the memory you need by working with singles.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2013년 5월 18일
Perhaps there are any magic tricks, which allow to compute A'*A. When you call the BLAS function through a MEX interface, A' is not calculated explicitly. Perhaps http://www.mathworks.com/matlabcentral/fileexchange/13604-calllapack-matlab-interface-of-lapack-and-blas-functions helps. But nothing can compete with real RAM: Install a 64 bit version and a bunch of GigaBytes. This will be cheaper than about 1 to 2 hours of work with a usual salary for an engineer.
  댓글 수: 3
Jan
Jan 2013년 5월 22일
@James: I assume this symmetric BLAS routine is triggered by the undocumented JIT acceleartion. Unfortunately I do not know its documentation, such that this could not matter my Matlab version.
Another point could be, that in A = rand(6000); B = A'*A two large matrices must exist at the same time. When A is not required anymore, an inplace construction would be useful. The original BLAS-DGEMM does not exploit, that the result of A'*A is symmetric, as far as I know. Perhaps the MKL and ATLAS implementations do this.
James Tursa
James Tursa 2013년 5월 22일
편집: James Tursa 2013년 5월 22일
@Jan: I am unaware of any specific documentation covering the rules for when symmetric BLAS routines are called. The doc used to list the routines that were used (without giving rules for when they were used), but I don't even see that anymore. E.g., is the symmetric routine called for shared data copy cases such as this:
A = rand(6000);
C = A;
B = C'*A;
Given that the rules are not documented, I don't know if one can always depend on the symmetric behavior.
If you want to know what MATLAB is doing on your particular machine for a particular case, you can always compare the timing to MTIMESX in SPEED mode for a large case. MTIMESX will always key off of the real data pointer value to determine symmetric cases, so it will catch the shared data copy inputs. The timing difference for large symmetric multiplies is an obvious discriminator (something like 30% or more on my machine if I remember correctly). And the symmetric result won't in general match the DGEMM result.

댓글을 달려면 로그인하십시오.


Iain
Iain 2013년 5월 22일
Do it the old fashioned way using loops. - It means you do NOT need to have both A, its transpose and the result in memory, but it is slower.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by