You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been investigating a complete process hang during from sklearn.cluster import DBSCAN, and I've traced it to a call to numpy.finfo(float) in the scipy.linalg.decomp_schur module. The actual hang occurs in core/machar.pyline 227:
temp = z*t
This line is within a for loop and occurs on the _ = 9 iteration. At that point I'm getting repr(z) = array([ 5.56268465e-309]), and repr(t) = array([ 1.]) (I don't know how to get a more accurate representation of their actual state). The next line is never reached — the process hangs indefinitely at the temp = z*t line.
The weirdest part is that the from sklearn.cluster import DBSCAN import works fine when I try it in a clean Python shell, but hangs when running in our web application. We're using numpy very sparsely, and we're certainly not messing with its internals, so I have no idea how to narrow down the conflict that apparently occurs between numpy and the rest of our codebase.
I'm running on a i686 Celeron, 32-bit Ubuntu installation. I think that's as vanilla as it can be.
The issue occurs in a WSGI web application running under Apache, I'm not really sure how to approach debugging it within Apache. Running it as a Python webserver does not trigger the issue, numpy.finfo(float) returns successfully.
My testcase is simply numpy.finfo(float). Hangs when running in Apache, works in the Python shell and as a standalone WSGI application.
The issue is using PyGILState_Ensure, which Python docs say is not compatible with sub-interpreters (which mod_wsgi uses in its default configuration).
@original filer: Does the WSGIApplicationGroup %{GLOBAL} hack work?
Anyone know if there's something we can/should do to fix this on our end?
The mod_wsgi docs are not very helpful to library writers.
On 1 Oct 2013 09:47, "Pauli Virtanen" [email protected] wrote:
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/3837#issuecomment-25433867
.
@njsmith: as far as I understand, replacing calls to PyGILState_Ensure with the other equivalent (?) Python mechanisms. However, also Cython uses PyGILState_Ensure, so it would not be enough to "fix" Numpy.
Python sub-interpreters probably don't mix well with any extension modules.
Gotcha. Well, sounds like something that if someone feels inspired to fix
then that'd be cool, but not really urgent given how many libraries have
this problem with mod_wsgi and that there are well documented workarounds.
On 1 Oct 2013 10:16, "Pauli Virtanen" [email protected] wrote:
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/3837#issuecomment-25435316
.
I am experiencing this freeze (on the exact same line of code) on Numpy 1.11.3 in an application that does not use wsgi (it's not a web app) or sub-interpreters. The code runs fine on my desktop but freezes deterministically when I run it on the Cori supercomputer, which runs an Intel KNL architecture.
Is there any good way to determine what components might be responsible? At the moment I don't have any good ways to debug this.
The code is still there in current NumPy, but has been superseded and should not be accessed in normal use from finfo if you have a standard floating type. If it gets fixed in the future, it will preferably be by removal. Could you try a more recent NumPy and see if that fixes the problem?
Activity
juliantaylor commentedon Sep 30, 2013
what kind of hardware are you using? np.finfo has issues on some machines, see e.g. #3125
can you produce a small testcase?
juliantaylor commentedon Sep 30, 2013
that its hanging on z*t is very strange, can you debug into this with gdb?
lanzz commentedon Oct 1, 2013
I'm running on a i686 Celeron, 32-bit Ubuntu installation. I think that's as vanilla as it can be.
The issue occurs in a WSGI web application running under Apache, I'm not really sure how to approach debugging it within Apache. Running it as a Python webserver does not trigger the issue,
numpy.finfo(float)returns successfully.My testcase is simply
numpy.finfo(float). Hangs when running in Apache, works in the Python shell and as a standalone WSGI application.lanzz commentedon Oct 1, 2013
Minimal WSGI application that reproduces the issue when executed under
mod_wsgi:Exception is never raised, request hangs without response.
pv commentedon Oct 1, 2013
Which Ubuntu version, and which apache/mod_wsgi package versions?
pv commentedon Oct 1, 2013
Googling "numpy mod_wsgi": http://serverfault.com/questions/514242/non-responsive-apache-mod-wsgi-after-installing-scipy
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
pv commentedon Oct 1, 2013
The issue is using
PyGILState_Ensure, which Python docs say is not compatible with sub-interpreters (which mod_wsgi uses in its default configuration).njsmith commentedon Oct 1, 2013
That sounds like a pretty plausible explanation.
@original filer: Does the WSGIApplicationGroup %{GLOBAL} hack work?
Anyone know if there's something we can/should do to fix this on our end?
The mod_wsgi docs are not very helpful to library writers.
On 1 Oct 2013 09:47, "Pauli Virtanen" [email protected] wrote:
pv commentedon Oct 1, 2013
@njsmith: as far as I understand, replacing calls to
PyGILState_Ensurewith the other equivalent (?) Python mechanisms. However, also Cython usesPyGILState_Ensure, so it would not be enough to "fix" Numpy.Python sub-interpreters probably don't mix well with any extension modules.
njsmith commentedon Oct 1, 2013
Gotcha. Well, sounds like something that if someone feels inspired to fix
then that'd be cool, but not really urgent given how many libraries have
this problem with mod_wsgi and that there are well documented workarounds.
On 1 Oct 2013 10:16, "Pauli Virtanen" [email protected] wrote:
lanzz commentedon Oct 1, 2013
Yes, the
WSGIApplicationGroup %{GLOBAL}hack works. Thanks for the help, I wasn't able to narrow my searches enough to find that SO question.In my case this is an acceptable workaround, probably it would be good to have it prominently documented somewhere?
ndjensen commentedon May 8, 2015
This is definitely not a trivial thing to solve, but if you wanted to replace PyGILState_Ensure() then I think you can as long as you have the PyThreadState*. Getting that could be tricky, Jep uses the PyThreadState_GetDict() method. See https://github.com/mrj0/jep/blob/v3.3.0rc/src/jep/pyembed.c#L351
For an example of Jep doing this, see https://github.com/mrj0/jep/blob/v3.3.0rc/src/jep/pyembed.c#L708
elliottslaughter commentedon Jun 25, 2018
I am experiencing this freeze (on the exact same line of code) on Numpy 1.11.3 in an application that does not use wsgi (it's not a web app) or sub-interpreters. The code runs fine on my desktop but freezes deterministically when I run it on the Cori supercomputer, which runs an Intel KNL architecture.
Is there any good way to determine what components might be responsible? At the moment I don't have any good ways to debug this.
charris commentedon Jun 25, 2018
The code is still there in current NumPy, but has been superseded and should not be accessed in normal use from finfo if you have a standard floating type. If it gets fixed in the future, it will preferably be by removal. Could you try a more recent NumPy and see if that fixes the problem?
elliottslaughter commentedon Jun 27, 2018
I upgraded to NumPy 1.13.3 and the problem went away. Thank you!
charris commentedon Jun 27, 2018
Thanks for checking.