<h4 dir="auto">Description</h4>
<p dir="auto">I have a malloc error with TruncatedSVD.<br>
My issue seems closed to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="182033512" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/7626" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/7626/hovercard" href="https://github.com/scikit-learn/scikit-learn/issues/7626">#7626</a></p>
<h4 dir="auto">Steps/Code to Reproduce</h4>
<p dir="auto">Code to reproduce my error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
from sklearn import decomposition
from sklearn.pipeline import make_pipeline
from sklearn.datasets import fetch_20newsgroups

twenty_train = fetch_20newsgroups(subset='train')
twenty_test = fetch_20newsgroups(subset='test')

dt_svd_clf = make_pipeline(CountVectorizer(), 
                           decomposition.TruncatedSVD(n_components=25), 
                          )
dt_svd_clf.fit(twenty_train.data, twenty_train.target)"><pre lang="{python}" class="notranslate"><code class="notranslate">from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer
from sklearn import decomposition
from sklearn.pipeline import make_pipeline
from sklearn.datasets import fetch_20newsgroups

twenty_train = fetch_20newsgroups(subset='train')
twenty_test = fetch_20newsgroups(subset='test')

dt_svd_clf = make_pipeline(CountVectorizer(), 
                           decomposition.TruncatedSVD(n_components=25), 
                          )
dt_svd_clf.fit(twenty_train.data, twenty_train.target)
</code></pre></div>
<p dir="auto">python crashes with a segfault:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python(1883,0x7fff79fe5000) malloc: *** mach_vm_map(size=18446744072715628544) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Segmentation fault: 11"><pre class="notranslate"><code class="notranslate">python(1883,0x7fff79fe5000) malloc: *** mach_vm_map(size=18446744072715628544) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Segmentation fault: 11
</code></pre></div>
<p dir="auto">I reproduce the bug all the time.<br>
I have 8GB RAM on my computer and I have some enough RAM left when running the code.<br>
With algorithm='arpack' it works. I can even set n_components to 250 for instance.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="dt_svd_clf = make_pipeline(CountVectorizer(), 
                           decomposition.TruncatedSVD(algorithm='arpack',n_components=25), 
                          )"><pre class="notranslate"><code class="notranslate">dt_svd_clf = make_pipeline(CountVectorizer(), 
                           decomposition.TruncatedSVD(algorithm='arpack',n_components=25), 
                          )
</code></pre></div>
<h4 dir="auto">Versions</h4>
<p dir="auto">My configuration:<br>
Darwin-15.6.0-x86_64-i386-64bit<br>
Python 3.5.2 (default, Oct 11 2016, 15:01:29)<br>
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]<br>
NumPy 1.11.2<br>
SciPy 0.18.1<br>
Scikit-Learn 0.18.1</p>
<p dir="auto">Thanks</p>
<h4 dir="auto">Description</h4>
<p dir="auto">I tried to use PCA with default configuration on MNIST dataset, It gave memory allocation error. The code given below worked well in the previous version of scikit-learn(0.17). The PCA class chooses the randomised svd solver for this dataset, whereas in the previous version it was just svd_solver='full'. If I give explicitly svd_solver='full', it works fine, but when I leave it to find the best solver it chooses randomized svd solver and the code gives memory allocation error when it tries to calculate linalg.lu() using Scipy.</p>
<h4 dir="auto">Steps/Code to Reproduce</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from sklearn.model_selection import train_test_split
from sklearn.datasets import fetch_mldata
from sklearn.decomposition import PCA

mnist = fetch_mldata('MNIST original', data_home='./data')
X_train, X_test, y_train, y_test = train_test_split(mnist.data, mnist.target, test_size=0.3, random_state=0)

pca = PCA(n_components=100)
pca.fit_transform(X_train)
"><pre class="notranslate"><code class="notranslate">from sklearn.model_selection import train_test_split
from sklearn.datasets import fetch_mldata
from sklearn.decomposition import PCA

mnist = fetch_mldata('MNIST original', data_home='./data')
X_train, X_test, y_train, y_test = train_test_split(mnist.data, mnist.target, test_size=0.3, random_state=0)

pca = PCA(n_components=100)
pca.fit_transform(X_train)

</code></pre></div>
<h4 dir="auto">Error</h4>
<p dir="auto">Python(17010,0x7fffa552c3c0) malloc: *** mach_vm_map(size=18446744066138652672) failed (error code=3)<br>
*** error: can't allocate region<br>
*** set a breakpoint in malloc_error_break to debug</p>
<h4 dir="auto">Versions</h4>
<p dir="auto">Darwin-16.0.0-x86_64-i386-64bit<br>
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]<br>
NumPy 1.11.2<br>
SciPy 0.18.1<br>
Scikit-Learn 0.18</p>