question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NumPy "dot" hangs when used with multiprocessing (potentially Apple Accelerate related?)

See original GitHub issue

I’m having a devil of a time making a minimal test case, but this seems to be my issue: http://stackoverflow.com/questions/23963997/python-child-process-crashes-on-numpy-dot-if-pyside-is-imported

In my case, I have code that farms out a bunch of calculations, including matrix products to a multiprocessing.Pool with pool.map. The computation hangs partway through, and some hacky print-based debugging shows it hanging on a call to np.dot down in the guts of the program.

Replacing pool.map with the built-in (serial) map makes everything work.

I used not to have this issue, then something changed (lunar eclipse?) and now my computation hangs consistently whenever multiprocessing is used. A minimal test case continues to elude me. (It’s not enough to simply generate 10 random NxN arrays and dot them in a multiprocessing-based way.)

>>> numpy.show_config()
lapack_opt_info:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    extra_compile_args = ['-msse3', '-DAPPLE_ACCELERATE_SGEMV_PATCH']
    define_macros = [('NO_ATLAS_INFO', 3)]
openblas_lapack_info:
  NOT AVAILABLE
atlas_3_10_blas_threads_info:
  NOT AVAILABLE
atlas_threads_info:
  NOT AVAILABLE
atlas_3_10_threads_info:
  NOT AVAILABLE
atlas_blas_info:
  NOT AVAILABLE
atlas_3_10_blas_info:
  NOT AVAILABLE
atlas_blas_threads_info:
  NOT AVAILABLE
openblas_info:
  NOT AVAILABLE
blas_mkl_info:
  NOT AVAILABLE
blas_opt_info:
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
    extra_compile_args = ['-msse3', '-DAPPLE_ACCELERATE_SGEMV_PATCH', '-I/System/Library/Frameworks/vecLib.framework/Headers']
    define_macros = [('NO_ATLAS_INFO', 3)]
atlas_info:
  NOT AVAILABLE
atlas_3_10_info:
  NOT AVAILABLE
lapack_mkl_info:
  NOT AVAILABLE
mkl_info:
  NOT AVAILABLE

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:28 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Jun 12, 2020

setting:

os.environ.update(MKL_NUM_THREADS='1')

fixed the issue for me

0reactions
ogriselcommented, Jan 24, 2017

It can be related. For Python 2.7 users (and Python 3 users as well), we started an alternative module to safely work with sub-processes without fearing those kinds of crashes and hanging:

https://github.com/tomMoral/loky

It’s still beta but we would be glad to get your feedback as github issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python child process crashes on numpy dot if PySide is ...
Yes it is issue with combining multiprocessing, pyside and blas numpy dot. If you remove one component, it doesn't hang (and your code...
Read more >
Changements — Documentation Python 3.5.10
Fix possible integer overflows and crashes in the mmap module with unusual usage patterns. bpo-1703178: Fix the ability to pass the –link-objects option...
Read more >
scikit-learn user guide
In Python 3.4+ it is now possible to configure multiprocessing to use the 'forkserver' or 'spawn' start methods.
Read more >
Package List — Spack 0.20.0.dev0 documentation
This is a list of things you can install using Spack. It is automatically generated based on the packages in this Spack version....
Read more >
Changelog — Python 3.4.3 documentation
Issue #23996: Avoid a crash when a delegated generator raises an unnormalized StopIteration exception. Patch by Stefan Behnel.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found