title: keras + scikit-learn wrapper, appears to hang when GridSearchCV with n_jobs >1
body: <p><strong>UPDATE</strong>: I have to re-write this question as after some investigation I realise that this is a different problem. </p>
  
  <p>Context: running keras in a gridsearch setting using the kerasclassifier wrapper with scikit learn. Sys: Ubuntu 16.04, libraries: anaconda distribution 5.1, keras 2.0.9, scikitlearn 0.19.1, tensorflow 1.3.0 or theano 0.9.0, <strong>using CPUs only.</strong></p>
  
  <p><strong>Code:</strong>
  I simply used the code here for testing: <a href="https://machinelearningmastery.com/use-keras-deep-learning-models-scikit-learn-python/" rel="nofollow noreferrer">https://machinelearningmastery.com/use-keras-deep-learning-models-scikit-learn-python/</a>, the second example 'Grid Search Deep Learning Model Parameters'. Pay attention to line 35, which reads:</p>
  
  <pre><code>grid = GridSearchCV(estimator=model, param_grid=param_grid)
  </code></pre>
  
  <p><strong>Symptoms:</strong> When grid search uses <strong>more than 1</strong> jobs (means cpus?), e.g.,, setting 'n_jobs' on the above line A to '2', line below:</p>
  
  <pre><code>grid = GridSearchCV(estimator=model, param_grid=param_grid, n_jobs=2)
  </code></pre>
  
  <p>will cause the code to hang indefinitely, either with tensorflow or theano, and there is no cpu usage (see attached screenshot, where 5 python processes were created but none is using cpu). </p>
  
  <p><a href="https://i.stack.imgur.com/tUoYr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tUoYr.png" alt="enter image description here"></a></p>
  
  <p>By debugging, it appears to be the following line with <strong>'sklearn.model_selection._search'</strong> that causes problems:</p>
  
  <pre><code>line 648: for parameters, (train, test) in product(candidate_params,
                                                 cv.split(X, y, groups)))
  </code></pre>
  
  <p>, on which the program hangs and cannot continue.</p>
  
  <p>I would really appreciate some insights as to what this means and why this could happen.</p>
  
  <p>Thanks in advance</p>