linear least squares/mldivide for large matrices in parallel?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a really large system to solve using linear least squares. The A matrix can have 2-3 million rows and 2000-3000 columns. The B matrix has same row size but with a single column.
I have access to a supercomputer, and I want to run the x = A\B (or) mldivide(A,B) command in parallel, since I can easily run out of RAM even on workstations with lots of memory.
Any ideas? I am able to run EIG and SVD without any issues in parallel, since I assume it is automatically parallelized by MATLAB. What about linear least squares? Suggestions outside of MATLAB are also welcome. Thanks.
댓글 수: 0
채택된 답변
Edric Ellis
2015년 4월 8일
편집: Edric Ellis
2015년 4월 8일
If you have access to a cluster of machines, you could use distributed arrays to solve the large system in parallel using the multiple memories. You'll need MATLAB Distributed Computing Server worker licenses on the cluster, and Parallel Computing Toolbox on the client machine. Something like this:
parpool();
A = distributed.rand(20000,2000);
b = sum(A, 2);
x = A\b;
댓글 수: 3
David
2016년 7월 27일
Okay so how do I then load up my distributed matrix? It seems that distributed arrays don't support non scalar right hand assignment... do I really need to loop through the entire 200,000 x 20,000 array in my case one by one? Won't this be really slow compared with the vectorized matrix manipulations I was using before?
I tried stuffing the matrix and then distributing it, but its over my single thread RAM limit at this point.
Sean de Wolski
2016년 7월 27일
David, please ask this in a new question - the answer will end up being to use codistributed arrays inside of spmd.
추가 답변 (1개)
Mahdiyar
2015년 4월 8일
Hi Arvind
Parallel computing helps you to use more amount of CPU to run your simulation in a shorter time. As well as I know, when you have memory problem, it does not help you.
What I can suggest you is that you can implement the "x=A\B" by your own code.
I mean that write the m-file to calculate this x = A\B. The only difference is that you have to save your data and delete another one when you do not need it to avoid Memory problem.
For example, to calculate the A\B, you need to calculate A^(-1). Thus, first, JUST load matrix A and calculate A^(-1) and then save that matrix as a matrix and delete matrix A (be cause you do not need it anymore).
I hope it helps you.
Regards,
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Distributed Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!