title: using multiprocessing with theano
body: <p>I'm trying to use theano with cpu-multiprocessing with a neural network library, Keras.</p>
  
  <p>I use <code>device=gpu</code> flag and load the keras model. Then for extracting features for over a million images, im using multiprocessing pool.</p>
  
  <p>The function looks something like this:</p>
  
  <pre><code>from keras import backend as K
  
  f = K.function([model.layers[0].input, K.learning_phase()], [model.layers[-3].output,])
  
  def feature_gen(flz):
      im = imread(flz)
      cPickle.dump(f([im, 0])[0][0], open(flz, 'wb'), -1)
  
  pool = mp.Pool(processes=10)
  results = [pool.apply_async(feature_gen, args=(f, )) for f in filelist]]
  </code></pre>
  
  <p>This however starts creating pools in the GPU memory and my code fails with memory error. Is it possible to force multiprocessing to create threads in CPU memory and then use specific parts for feature extraction such as <code>f([im, 0])[0][0]</code> with GPU?</p>
  
  <p>If not, is there an alternative to do the same thing in parallel in python?</p>