Skip to content

Fix numba warning on Linux for using TBB#2010

Open
psavery wants to merge 1 commit into
masterfrom
fix-numba-warning
Open

Fix numba warning on Linux for using TBB#2010
psavery wants to merge 1 commit into
masterfrom
fix-numba-warning

Conversation

@psavery
Copy link
Copy Markdown
Collaborator

@psavery psavery commented May 13, 2026

This fixes the following numba warning on Linux:

Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.

The main idea is that forked subprocesses (which we indeed do, in order to take advantage of copy-on-write mechanics and let subprocesses share data), which only happen on Linux (Windows and Mac do "spawn"), would always print this numba warning, even though we were never actually using TBB in an invalid way.

There's no way to suppress this warning, so we switch to OpenMP on Linux, which is just as performant.

In fact, it has one better feature too: it will crash if we try to run numba in parallel mode on a forked subprocess. TBB was just undefined, but the OpenMP implementation will actually crash, which prevents developers from ever doing that.

This fixes the following numba warning on Linux:

```
Numba: Attempted to fork from a non-main thread, the TBB library may be in an invalid state in the child process.
```

The main idea is that forked subprocesses (which we indeed do, in order
to take advantage of copy-on-write mechanics and let subprocesses share
data), which only happen on Linux (Windows and Mac do "spawn"), would
always print this numba warning, even though we were never actually using
TBB in an invalid way.

There's no way to suppress this warning, so we switch to OpenMP on Linux,
which is just as performant.

In fact, it has one better feature too: it will crash if we try to run
numba in parallel mode on a forked subprocess. TBB was just undefined,
but the OpenMP implementation will actually crash, which prevents
developers from ever doing that.

Signed-off-by: Patrick Avery <patrick.avery@kitware.com>
@psavery psavery requested a review from bnmajor May 13, 2026 22:13
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.

1 participant