8000 BUG: Binary Builds Deadlock due to OpenBLAS threading issue · Issue #30733 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Binary Builds Deadlock due to OpenBLAS threading issue #30733

@pv101

Description

@pv101

Describe the issue:

Opening a new issue as requested in #30092. The reproducer code hangs when run with numpy 2.4.1 installed via pip. It can be made to work by setting OMP_NUM_THREADS=1 or OMP_NUM_THREADS=2. Details of exact process I followed to install numpy and run the tests are below, where numpytest.py is the reproducer code:

% python3.12 -m venv np-venv
% source np-venv/bin/activate
(np-venv) % pip install --no-cache-dir numpy==2.4.1
Collecting numpy==2.4.1
  Obtaining dependency information for numpy==2.4.1 from https://files.pythonhosted.org/packages/b8/e0/1f9585d7dae8f14864e948fd7fa86c6cb72dee2676ca2748e63b1c5acfe0/numpy-2.4.1-cp312-cp312-macosx_11_0_arm64.whl.metadata
  Downloading numpy-2.4.1-cp312-cp312-macosx_11_0_arm64.whl.metadata (6.6 kB)
Downloading numpy-2.4.1-cp312-cp312-macosx_11_0_arm64.whl (12.4 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.4/12.4 MB 44.3 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-2.4.1

[notice] A new release of pip is available: 23.2.1 -> 25.3
[notice] To update, run: pip install --upgrade pip
(np-venv) % OMP_NUM_THREADS=1 python3.12 numpytest.py
(np-venv) % OMP_NUM_THREADS=2 python3.12 numpytest.py
(np-venv) % OMP_NUM_THREADS=4 python3.12 numpytest.py
^Z
zsh: suspended  OMP_NUM_THREADS=4 python3.12 numpytest.py
(np-venv) % kill %1
[1]  + terminated  OMP_NUM_THREADS=4 python3.12 numpytest.py
(np-venv) % python3.12 numpytest.py
^Z
zsh: suspended  python3.12 numpytest.py
(np-venv) % kill %1
[1]  + terminated  python3.12 numpytest.py

Reproduce the code example:

import numpy as np
import os

# Do some algebra
A = np.random.randn(216, 216)
np.linalg.inv(A)

# Fork but have the child do nothing
if (pid := os.fork()) != 0:
    # Deadlock!
    np.linalg.inv(A)

    # Wait for the child
    os.waitpid(pid, 0)

Error message:

Python and NumPy Versions:

2.4.1
3.12.0 (main, Oct 5 2023, 15:44:07) [Clang 14.0.3 (clang-1403.0.22.14.1)]

Mac OS 13.6.7

Runtime Environment:

No response

How does this issue affect you or how did you find it:

No response

(formatted by @mattip)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0