Description
Original ticket http://projects.scipy.org/numpy/ticket/2201 on 2012-08-14 by trac user agchang, assigned to @pv.
There seems to be an issue with numpy.linalg being called in unison with python's multiprocessing module. When invoking a numpy.linalg method from within a subprocess, e.g., through a worker pool and map() function, the program hangs and ignores all interrupt signals.
The code provided below will demonstrate the case:
import numpy as np
import multiprocessing as mp
def foo(x):
print np.linalg.inv([[2,3],[2,2]]) #this causes the crash
#print np.dot([[1,2],[3,4]],[[1,2],[3,4]]) # this works fine
def test():
print "running..."
print np.__version__
print mp.__version__
vals = [1,2,3,4]
#pool = mp.Pool(1) #This has an issue
#pool = mp.Pool(mp.cpu_count()) #this has an issue
pool.map(foo, vals)
if __name__ == "__main__":
test()
#foo(1) #this works fine
By hang I mean the program becomes unresponsive and does not respond to interrupts(Ctrl-C).
I took a look using pdb and it seems that it hangs after the call
waiter.acquire() in threading.py(the python system module) so I suspect some sort of deadlock?
multiprocessing.version is 0.70a1
numpy.version is 1.6.1
Some potentially related packages?
ii libblas3gf 1.2.20110419-2 Basic Linear Algebra Reference implementatio
ii liblapack3gf 3.3.1-1 library of linear algebra routines 3 - share
ii python 2.7.3-0ubuntu2 interactive high-level object-oriented langu
ii python-numpy 1:1.6.1-6ubunt Numerical Python adds a fast array facility
My kernel version is(uname -a):
Linux agc 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Let me know for any additional information.
Thanks.