I noticed a bug in the latest version of Numba (0.41.0) which involves repeatedly calling a cached Numba JIT compiled function that contains a print statement. To be more precise, everything works as expected for the first call, after which the function is cached. For subsequent calls to the same (now cached) function, a RuntimeError: missing Environment is thrown. This issue is related to issue #2411 which was fixed in a recent release.
Example: numba_print_test.py
from numba import njit
@njit(cache=True)
def test_inner(x):
print(x)
@njit(cache=True)
def test_outer(x):
test_inner(x)
test_outer(5)
The issue I observe is as follows: If cache=True for both the inner and outer function, everything works fine for the first call to numba_print_test.py. After this initial call the function is cached and no longer works for subsequent calls:
$ python numba_print_test.py
5
$ python numba_print_test.py
Traceback (most recent call last):
File "numba_print_test.py", line 14, in <module>
test_outer(5)
RuntimeError: missing Environment
It works fine if cache=False for both the inner and outer function:
$ python numba_print_test.py
5
$ python numba_print_test.py
5
It works fine if we set cache=True for the inner function, but keep cache=False for the outer function:
$ python numba_print_test.py
5
$ python numba_print_test.py
5
It no longer works if we set cache=False for the inner function and cache=True for the outer function:
$ python numba_print_test.py
5
$ python numba_print_test.py
Traceback (most recent call last):
File "numba_print_test.py", line 14, in <module>
test_outer(5)
RuntimeError: missing Environment
This seems to suggest that the issue is related to calling the cached outer function. In addition, if I delete the __pycache__ folder I can successfully call numba_print_test.py function once more, after which subsequent calls will again throw the RuntimeError.
Thanks for the report, I can reproduce, this indeed likely to be related to https://github.com/numba/numba/issues/2411
Likewise, encountering the same issue. In my case it seemed to work fine for a few cases but then started throwing the error predictably after the first run.
Temporarily resolved by disabling caching per @brunojacobs description.
PS - I am using v0.43.1
Curious if this is still on the radar? Thanks.
@songololo Yes it's still known, there's now a caching label, and sometime next year we're going to have a big caching fixing session as there's a number of interconnected things that need addressing.
Most helpful comment
@songololo Yes it's still known, there's now a
cachinglabel, and sometime next year we're going to have a big caching fixing session as there's a number of interconnected things that need addressing.