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.

Numba workqueue threading error

See original GitHub issue

Thanks for the great library!

I’m getting the following error: Terminating: Nested parallel kernel launch detected, the workqueue threading layer does not supported nested parallelism. Try the TBB threading layer.

The context is that I’m calling the umap library from flask and two clients are hitting a umap call at the same time. I’m guessing this is what is causing nested threading – flask is already using some kind of threading, and umap seems to be doing the same under the hood. I think this is related to numba threading, but I’m setting a random seed so as per the docs I don’t think this should be an issue.

Is there a proposed/preferred solution to this issue?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
celinesincommented, Jun 14, 2021

And, in the end my problem was incorrect wsgi configuration… what a treasure hunt! It works now, thanks for all the support!

1reaction
stuartarchibaldcommented, Jun 11, 2021

The most common cause of this issue is nesting parallel kernels, here’s an example:

from numba import njit, prange
import numpy as np

@njit(parallel=True)
def nested(x):
    for i in prange(len(x)):
        x[i] += 1


@njit(parallel=True)
def main():
    Z = np.zeros((5, 10))
    for i in prange(Z.shape[0]):
        nested(Z[i]) # A parallel region is calling another function with a parallel region!
    return Z

main()

The workqueue threading layer does not support nested kernels, whereas OpenMP and TBB do. The message you are seeing is coming from the workqueue threading layer as it’s detected that the code does something it doesn’t support and is “protecting” itself from inevitable corruption that would occur were it to attempt to run it.

My first question is… do you have something like the case above or do you have a parallel kernel being called from two python threads? I think the effect would manifest in the same error message as the workqueue backend isn’t threadsafe and it would “see” parallel region launches from two python threads as a kind of nest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Threading Layers — Numba 0.50.1 documentation
In practice, the only threading layer guaranteed to be present is workqueue . The omp layer requires the presence of a suitable OpenMP...
Read more >
Nested parallel kernel launch detected, the workqueue ...
I understand that the error says to Try the TBB threading layer but these tests were passing previously without TBB on MacOS and...
Read more >
numba/numba - Gitter
I think this is a bug. Seems to only fail in the workqueue threading layer though, so perhaps try installing tbb ( conda...
Read more >
TypeError: No matching version. GPU ufunc requires array ...
error: TypeError: No matching version. ... I am just started looking into numba's GPU capabilities. ... Workqueue Threading layer available : True. __Numba ......
Read more >
Performance Comparison of Python Translators for a Multi ...
for a Multi-threaded CPU-bound Application ... comes to parallelizing algorithms; while Numba and Cython achieved sig-.
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