How to troubleshoot an 'Out of memory' error with pca() when matlab still has plenty of RAM free?
4 views (last 30 days)
Show older comments
Could you help troubleshoot an 'Out of memory' error when running pca() on a 6000 x 9500 matrix of doubles?
To reproduce the error, run:
pca(rand(6000, 9500));
This produces the error:
Error using svd
Out of memory. Type "help memory" for your options.
Error in pca>localSVD (line 484)
[U,sigma,coeff] = svd(x, 'econ');
More specifically, pca will work on 6000x5000 but not an 6000x6000 matrix.
There should not be an 'Out of memory' error here because:
- matlab still has plenty of RAM available: this system has 32 GB of RAM and the matlab process nevers consumes more than 15% of that, even during pca (according to the 'top' command in ubuntu).
- R does PCA on that matrix without problem ;-)
Operating systems limits don't seem to be the solution:
A. running 'ulimit' on the command line suggests no memory limits:
$ ulimit -a
-t: cpu time (seconds) unlimited
-f: file size (blocks) unlimited
-d: data seg size (kbytes) unlimited
-s: stack size (kbytes) 8192
-c: core file size (blocks) 0
-m: resident set size (kbytes) unlimited
-u: processes 126664
-n: file descriptors 1024
-l: locked-in-memory size (kbytes) 16384
-v: address space (kbytes) 12582912
-x: file locks unlimited
-i: pending signals 126664
-q: bytes in POSIX msg queues 819200
-e: max nice 0
-r: max rt priority 0
-N 15: unlimited
B. Matlab is running in a 64-bit environment: ubuntu 18 LTS 64 bit with Matlab R2019b. The 'computer' matab command returns 'GLNXA64' so I believe I am using the 64-bit version of matlab. The 'ver' command also reports an x86_64 architecture and a 64-bit java hotspot server.
This question has been asked before. But it seems relevant to ask it again because all previous questions refered to the old implementaiton of pca (princomp()), are for systems with significantly less RAM (8 GB), for 32 bit environments, or were caused by issues in the data matrix (such as NaNs filling one column).
8 Comments
Hari Krishna Ravuri
on 17 Mar 2020
I failed to reproduce this behaviour on my end. Please provide reproduction steps.
Answers (0)
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!