python - Parallel code hangs if run first, but works if run after running non-parallel code -


so sounds bit convoluted, i've had problem joblib lately create bunch of processes , hang there (aka, each process takes memory, uses no cpu time).

here simplest code i've got reproduce problem:

from sklearn import linear_model import numpy np sklearn import cross_validation cval joblib import parallel, delayed  def fit_hanging_model(n=10000, nx=10, ny=32, ndelay=10,                        n_cvs=5, n_jobs=none):     # create data     x = np.random.randn(n, ny*ndelay)     y = np.random.randn(n, nx)      # create model + cv     model = linear_model.ridge(alpha=1000.)     cvest = cval.kfold(n, n_folds=n_cvs, shuffle=true)      # fit model     par = parallel(n_jobs=n_jobs, verbose=10)     parfunc = delayed(_fit_model_cvs)     par(parfunc(x, y, train, test, model)                       i, (train, test) in enumerate(cvest))  def _fit_model_cvs(x, y, train, test, model):     model.fit(x, y)    n = 10 = np.random.randn(n, 32)  b = np.random.randn(32, 10)  ########## c = np.dot(a, b) ##########  fit_hanging_model(n_jobs=3) 

here happens:

  • if run of code above, spawns off 3 processes , hangs
  • if run of code above, use n_jobs=1, works fine
  • if run of code above second time, after running once n_jobs=1, works fine no matter how many jobs use.
  • if run of code above except code between ######, runs fine.
  • however, if run code between ######, , try run fit_hanging_model n_jobs > 1, hangs

this joblib = 0.8.0, , sklearn 0.15-git.

note, bug on centos on linux. have not been able reproduce bug on machine, may hard reproduce.

does have idea why might going on? seems dot product doing strange, have no idea be...i'm @ end of rope...

figured out. apparently issue joblib creating multiple python processes, while mkl simultaneously trying threading. see issue , solution (which involves setting environment variables) here:

https://github.com/joblib/joblib/issues/138


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -