title: PCA memory error on GCP Compute Engine virtual machine
body: <p>I created a virtual machine on GCP Compute Engine with Windows Server 2016, with n1-highmem-4 (4 vCPUs, 2.2 GHz CPU, 26 GB memory) and 50GB of disk size at europe-west2 datacenter location.</p>
  
  <p>I installed Pycharm in it and I run a simple PCA with python and scikit-learn on some images of resolution 529x940.
  However, when I am running this on (only) 1000 rgb images then I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:/Users/User/PycharmProjects/Sample/Main.py", line 130, in &lt;module&gt;
      pca.fit(data)
    File "C:\Users\User\PycharmProjects\Sample\venv\lib\site-packages\sklearn\decomposition\pca.py", line 329, in fit
      self._fit(X)
    File "C:\Users\User\PycharmProjects\Sample\venv\lib\site-packages\sklearn\decomposition\pca.py", line 370, in _fit
      copy=self.copy)
    File "C:\Users\User\PycharmProjects\Sample\venv\lib\site-packages\sklearn\utils\validation.py", line 444, in check_array
      array = np.array(array, dtype=dtype, order=order, copy=copy)
  MemoryError
  </code></pre>
  
  <p>My source code is the following:</p>
  
  <pre><code>import cv2
  import numpy as np
  import os
  import matplotlib.pyplot as plt
  from glob import glob
  from sklearn.decomposition import PCA
  from sklearn import neighbors
  from sklearn import preprocessing
  import shutil
  
  data = []
  i = 0
  # Number of images
  number = 800
  
  # Load images from file
  for filename in glob('Images/*.jpg'):
      img = cv2.imread(filename)
      height, width = img.shape[:2]
      img = np.array(img)
  
      if height == 529 and width == 940 and i &lt; number:
          i = i + 1
          # Transpose each individual rgb image to a row
          img = np.concatenate(img, axis=0)
          img = np.concatenate(img, axis=0)
          data.append(img)
  
  # Normalisation
  data = np.array(data)
  Norm = preprocessing.Normalizer()
  Norm.fit(data)
  data = Norm.transform(data)
  
  # PCA
  pca = PCA(0.95)
  pca.fit(data)
  data = pca.transform(data)
  print('Number of components:', pca.n_components_, '\n')
  </code></pre>
  
  <p>However, when I run the same python script on my laptop which only has a RAM of 8 GB along with a CPU of 2.7 GHz then I get no memory error for PCA when processing 800 images but it simply does not finish within a reasonable time (takes more than 8 hours)!</p>
  
  <p>How is it possible that I get a memory error for 800 rgb images for PCA in GCP virtual machine which has very large RAM and I do not get it on my laptop which has pretty low RAM?</p>