8000 DOC: site.cfg: warn against OpenBLAS and multiprocessing by larsmans · Pull Request #4194 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: site.cfg: warn against OpenBLAS and multiprocessing #4194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2014

Conversation

larsmans
Copy link
Contributor

Fixes #654 by not fixing it; I don't think NumPy can actually fix the problem as it's a design flaw in Python's multiprocessing. Listed various alternatives (Python 3.4 forkserver, single-threaded OpenBLAS, Python threading).

Maybe @ogrisel wants to chip in on this one as well?

@juliantaylor
Copy link
Contributor

I wouldn't say its a flaw in python, its even very useful for non portable code.
multithreaded ATLAS works fine with multiprocessing, openblas just does it in a way that can't deal with forking.

@larsmans
Copy link
Contributor Author

I don't know what workaround ATLAS uses, and I'm not looking for an argument about the merits of platform-specific hacks. But I've encountered so many people who came across this exact problem that I figured it should be documented in plenty of places and this seems like one of the right places.

@juliantaylor
Copy link
Contributor

right, but maybe add a note that ATLAS does not have this problem for users of older pythons.
btw I recently added similar docs to scipy.org: scipy/scipy.org#48

Fixes numpy#654 by not fixing it; I don't think NumPy *can* actually fix
the problem as it's a design flaw in Python's multiprocessing. Listed
various alternatives (Python 3.4 forkserver, single-threaded OpenBLAS,
Python threading).
@larsmans
Copy link
Contributor Author

Added a note about ATLAS.

@juliantaylor
Copy link
Contributor

thanks

juliantaylor added a commit that referenced this pull request Jan 14, 2014
DOC: site.cfg: warn against OpenBLAS and multiprocessing
@juliantaylor juliantaylor merged commit a724c93 into numpy:master Jan 14, 2014
@ogrisel
Copy link
Contributor
ogrisel commented Jan 15, 2014

Sounds like a good first step. In the future we might want to try to detect if numpy is linked against OpenBLAS or OSX Accelerate and automatically switch to either the multiprocessing forkserver or spawn modes in those cases (with a warning message).

@ogrisel
Copy link
Contributor
ogrisel commented Jan 15, 2014

My last comment was about the scikit-learn / joblib projects that use multiprocessing. For numpy I don't think we can do more than just documenting the limitation for threading libraries like OpenBLAS with unsafe forking programs that use the fork mode of multiprocessing.

@juliantaylor
Copy link
Contributor

I'm not convinced openblas can't be fixed so I'm not in favor of implementing a bunch of complicated workarounds. But I did not find time to try fixing it yet.

@juliantaylor
Copy link
Contributor

accelerate is a bigger problem as that can't be fixed ...

@ogrisel
Copy link
Contributor
ogrisel commented Jan 16, 2014

Here is a summary of my understanding of the problem:

AFAIK OpenBLAS has two modes: one without OpenMP (to be buildable with clang / llvm) and the other one that uses OpenMP and hence the GOMP implementation when built with GCC. By trying to understand how to "fix" the problem by contributing a hackish patch to libgomp and getting it rejected with constructive comments it is now my understanding that this is not possible: the POSIX OpenMP standard and the POSIX fork / thread standards are making it impossible to have safe fork without exec in an program that links against an OpenMP runtime. Hence the need to use Python 3.4's mutiprocessing spawn or forkerserver (without numpy / OpenBLAS preloading unfortunately).

One could try to convince the OpenBLAS maintainer to stick to manual thread pool handling and use pthreads_atfork to shutdown the main process threadpool prior to forking but this apparently not possible to do so with OpenMP without violating the standard.

For reference @juliantaylor @larsmans and I also discussed the problem on this OpenBLAS issue: OpenMathLib/OpenBLAS#294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

numpy.linalg and multiprocessing crash (Trac #2201)
3 participants
0