You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have included a self contained code sample to reproduce the problem.
i.e. it's possible to run as 'python bug.py'.
This will be a somewhat sparse bug report, but putting here early in case anyone recognizes this. We can do more work to replicate the environment if not.
In our upstream tests, xarray tests nightly against unreleased versions of our dependencies to get ahead of any incompatible code. Occasionally it also catches bugs in upstream libraries.
Here, we're getting an error importing some items from numba.np.ufunc, including the somewhat confusing SystemError: initialization of _internal failed without raising an exception at the bottom of the stack trace.
Reacted by Spencer Hallyburton, Ze Engida, Marco Edward Gorelli, Stanislas du Ché, arturdaraujo, Ievgenii Krevenets, Ray Bell, theimagelab, Aitor Duo Zubiaurre, Hanif Izzudin Rahman and 8 more
Thanks for the report @max-sixty. Do you know what version of Python, Numba and NumPy (and where from, e.g. conda-forge or pip or ...) were present when this a) failed and b) was last successful?
I think:
SystemError: initialization of _internal failed without raising an exception
is saying that the module failed to initialize as it returned an error code, but there was no exception raised to go with the failure result (e.g. function PyInit_<module name> returned NULL but an exception wasn't set).
Do you know what version of Python, Numba and NumPy (and where from, e.g. conda-forge or pip or ...) were present when this a) failed and b) was last successful?
This is the first day it's failed with this error, so it is likely to be a change somewhere in the past day.
Though I realize "somewhere" isn't that helpful, and it now seems that it may not be a numba-specific error given that hasn't changed. Do you possibly have any similar tests which run on the latest branch of numpy etc? If those pass, then this is more likely to be something specific to xarray / numbagg, even though that didn't look likely at first glance.
is saying that the module failed to initialize as it returned an error code, but there was no exception raised to go with the failure result (e.g. function PyInit_<module name> returned NULL but an exception wasn't set).
This is the first day it's failed with this error, so it is likely to be a change somewhere in the past day.
That's not quite true, it started failing 5 days ago but there was a bug in our CI which caused that to go unnoticed. Probably doesn't change too much, though.
Do you know what version of Python, Numba and NumPy (and where from, e.g. conda-forge or pip or ...) were present when this a) failed and b) was last successful?
This is the first day it's failed with this error, so it is likely to be a change somewhere in the past day.
Though I realize "somewhere" isn't that helpful, and it now seems that it may not be a numba-specific error given that hasn't changed. Do you possibly have any similar tests which run on the latest branch of numpy etc? If those pass, then this is more likely to be something specific to xarray / numbagg, even though that didn't look likely at first glance.
Thanks for this information. Numba doesn't automatically test against NumPy latest/mainline, but it does test NumPy alphas/pre-releases and provides feedback for these. Once a NumPy package becomes more generally available across a number of distribution mechanisms, support for that release of NumPy is added to Numba. As a result, released versions of Numba have explicit version constraints with respect to packages such as NumPy. As it's quite common for updates to e.g. NumPy to break something in Numba, Numba tries really hard to provide predicable failure modes (e.g. won't install or RuntimeError for unsupported NumPy being found).
Do you think it'd be possible to diff the logs between last working and now? That might hint at the problem?
is saying that the module failed to initialize as it returned an error code, but there was no exception raised to go with the failure result (e.g. function PyInit_<module name> returned NULL but an exception wasn't set).
Ah great, that makes much more sense.
Great, glad that's clearer, it's quite a "low level" problem.
I just checked, and as far as I can tell the only difference are some I/O libraries (unrelated, I think) and the OS version. We use the ubuntu-latest tag to run on github actions, and apparently that changed from 20.04.5 to 22.04.1. Not sure if that should make a difference? Edit: the version of __glibc changes as well: __glibc=2.31=0 → __glibc=2.35=0
Edit: For reference, here's the logs: passing (we have other errors, but they're definitely unrelated) and failing
Thanks for checking @keewis. I'm going to make some guesses based on Numba internals... I think the following:
That the issue is unlikely to be glibc, Python or Python C-API related as to get to the point of importing numba.np.ufunc._internal Numba would have had to have imported other C extension modules that would have similar glibc linkage and C-API use and these evidently worked "OK" as errors were not raised.
That whilst Numba guards against using unsupported NumPy versions, current NumPy nightlies are likely to be reporting that they are 1.23 series builds as IIRC 1.24 hasn't been tagged, so Numba is effectively using something that hasn't been tested.
Following some discussion at the weekly triage meeting, @gmarkall noted that there's some potential for susceptibility against changes in NumPy ufunc definitions in the init_ufunc_dispatch function in _internal.c. NumPy has recently merged a change to help with Update ufunc loop signature resolution to use NumPy #22422 #8538 which may well be the cause of the problem if 2. is also correct.
Numba relies on NumPy infrastructure for e.g. ufunc creation, and so there is a very tight coupling in this respect, between Numba and NumPy (the code is all in C and uses Python/NumPy C-API).
To debug and potentially fix the issue reported, maybe first try installing a supported released version of NumPy? If that fixes it, it narrows the problem down to what is suspected in the above.
To debug and potentially fix the issue reported, maybe first try installing a supported released version of NumPy? If that fixes it, it narrows the problem down to what is suspected in the above.
Our tests are still very much passing on the newest released versions of libraries; so this is only an issue with the versions from HEADs. I just tried installing numpy from main — I get the same failure with numba 0.56.3 but it works with numba 0.56.4. I notice that's consistent with the declared dependencies of numba, so it seems numba is doing everything it should be...
Possibly over at xarray, we should at least ensure we're on the latest numba for this test. I did a PR to do that earlier: pydata/xarray#7311 (review). Let us know if there's some pre-compiled version of dependencies (pydata/xarray#7311 (comment)), otherwise we'll just use pip.
Feel free to close, thanks for your attention @stuartarchibald !
for me numba=0.56.4 from conda-forge fails locally with numpy=1.24.0.dev0+1120.gf30af6acd, so not sure what I'm doing wrong? @max-sixty, was that with the numba head?
and pip does indeed complain that numba requires numpy<1.24 but installs it anyways (as intended in this case, because we do actually want to test with the most recent version, even if that breaks something). So while point 2 from #8615 (comment) does not apply, point 3 may very well be the cause of the problem.
Reacted by Spencer Hallyburton, Takuma Yoneda, Tim Stevens and Gabriel Gilbreath
both that nightly wheel command, and pip install . on numpy''s HEAD
both numba 0.56.3 and 0.56.4
So I think my prior success with 0.56.4 must have been a mistake (I notice that pip reinstalls a lower version of numpy when installing a new version of numba, so that may have been it, mea culpa)
...so I'm not sure what we should do from Xarray's POV — I guess we can try running tests without numba? But that misses some of the utility of these upstream tests.
This is a bugfix release to fix a regression in the CUDA target in relation to
the ``.view()`` method on CUDA device arrays that is present when using NumPy
version 1.23.0 or later.
Pull-Requests:
* PR `#8537 <https://github.com/numba/numba/pull/8537>`_: Make ol_compatible_view accessible on all targets (`gmarkall <https://github.com/gmarkall>`_)
* PR `#8552 <https://github.com/numba/numba/pull/8552>`_: Update version support table for 0.56.4. (`stuartarchibald <https://github.com/stuartarchibald>`_)
* PR `#8553 <https://github.com/numba/numba/pull/8553>`_: Update CHANGE_LOG for 0.56.4 (`stuartarchibald <https://github.com/stuartarchibald>`_)
* PR `#8570 <https://github.com/numba/numba/pull/8570>`_: Release 0.56 branch: Fix overloads with ``target="generic"`` for CUDA (`gmarkall <https://github.com/gmarkall>`_)
* PR `#8571 <https://github.com/numba/numba/pull/8571>`_: Additional update to CHANGE_LOG for 0.56.4 (`stuartarchibald <https://github.com/stuartarchibald>`_)
but in summary, it involved adding a couple of lines to fix a regression in <array>.view()-like capabilities on the CUDA hardware target. Something that should not in any way impact the issue above as it's all in JIT code generation and specifically for CUDA users.
changed the title [-]"SystemError: initialization of _internal failed without raising an exception"[/-][+]Error on import with numpy HEAD[/+]on Nov 23, 2022
...so I'm not sure what we should do from Xarray's POV — I guess we can try running tests without numba? But that misses some of the utility of these upstream tests.
I'm not sure what is best for the Xarray project, however this information might help informing that decision.
Numba's releases are restricted for use against specific versions of NumPy for reasons as demonstrated in this issue. It is often the case that Numba might "work" on other versions of NumPy, but this cannot be guaranteed as they might not be binary compatible etc.
Numba main branch has no restrictions on the version of NumPy, but it also doesn't track NumPy HEAD. The folks who maintain Numba do an upgrade of the supported NumPy version, often in a single patch, as pre-release packages become available for testing. I'll raise this issue with the other maintainers at the next triage meeting, but historically the view has been:
There are simply not the resources (human, packages, or compute) for Numba to track NumPy HEAD.
Development of Numba is considerably easier in stable environments. There are already many variations:
Python versions (the bytecode from which Numba compiles changes in literally every version)
NumPy versions (algorithms, APIs, etc change in pretty much every version)
OS/Architecture (Numba supports at least 7, each with their own individual issues)
I was having the same problem with the librosa library (The reason was that librosa was working with different versions of scipy and matplotlib), so I uninstalled numpy, matplotlib, and scipy, installed librosa first which installed its own compatible versions of libraries above and then I installed the necessary libraries. That seems to work for me.
Thank you all for your comments/feedback on this issue. This issue seems to have diverged a little from the originally reported problem and so I'm closing this issue as resolved with some specific follow up issues to subscribe to if they are important to you:
With respect to the originally posted issue, this comment Error on import with numpy HEAD #8615 (comment) (and some discussion immediately after) explains the decisions surrounding Numba not tracking NumPy HEAD.
With respect to the originally posted issue, NumPy 1.24 #8691 is the patch for making Numba compatible with NumPy 1.24.
The NumPy 1.24 related problem that manifests as the error:
SystemError: initialization of _internal failed without raising an exception
for me numba=0.56.4 from conda-forge fails locally with numpy=1.24.0.dev0+1120.gf30af6acd, so not sure what I'm doing wrong? @max-sixty, was that with the numba head?
and pip does indeed complain that numba requires numpy<1.24 but installs it anyways (as intended in this case, because we do actually want to test with the most recent version, even if that breaks something). So while point 2 from #8615 (comment) does not apply, point 3 may very well be the cause of the problem.
Thanks. This help a lot. I reinstall numpy by "pip install numpy==1.23.0". Then, the error when "import numba" was solved.
Reacted by Gabriel Gilbreath, Elliot Tower and Lydon Chandra
Hello everyone, the solutions posted here did not fix the problem for me. I tried numba v0.56.4 and v0.56.3 and both of these versions did not work with either numpy 1.23.0 or 1.24.0. I installed everything with conda-forge and I am using WSL. Any help would be greatly appreciated. Thank you!
Reacted by Isha Pathania, Nils Wildt, Nitin Madnani, GRISHANIN Vasiliy, Dmitry, Fred Frey, Julian Nubert, Somshubra Majumdar, bilzard, Jelmer Kuperus and 2 more
Hello everyone, the solutions posted here did not fix the problem for me. I tried numba v0.56.4 and v0.56.3 and both of these versions did not work with either numpy 1.23.0 or 1.24.0. I installed everything with conda-forge and I am using WSL. Any help would be greatly appreciated. Thank you!
I fixed with conda install cudatoolkit on a cpu only machine
Activity
stuartarchibald commentedon Nov 22, 2022
Thanks for the report @max-sixty. Do you know what version of Python, Numba and NumPy (and where from, e.g.
conda-forgeorpipor ...) were present when this a) failed and b) was last successful?I think:
is saying that the module failed to initialize as it returned an error code, but there was no exception raised to go with the failure result (e.g. function
PyInit_<module name>returnedNULLbut an exception wasn't set).max-sixty commentedon Nov 22, 2022
Thanks for the swift response @stuartarchibald !
Here's the full version info: https://github.com/pydata/xarray/actions/runs/3519182359/jobs/5906608476#step:8:74
Actually it seems we don't install the upstream version of numba, so this was running on
0.56.4 py310ha5257ce_0. FYI the script we use to install dependencies is at https://github.com/pydata/xarray/blob/main/ci/install-upstream-wheels.sh.This is the first day it's failed with this error, so it is likely to be a change somewhere in the past day.
Though I realize "somewhere" isn't that helpful, and it now seems that it may not be a numba-specific error given that hasn't changed. Do you possibly have any similar tests which run on the latest branch of
numpyetc? If those pass, then this is more likely to be something specific to xarray / numbagg, even though that didn't look likely at first glance.Ah great, that makes much more sense.
Add numba to nightly upstream
keewis commentedon Nov 22, 2022
That's not quite true, it started failing 5 days ago but there was a bug in our CI which caused that to go unnoticed. Probably doesn't change too much, though.
stuartarchibald commentedon Nov 22, 2022
No problem!
Thanks for this information. Numba doesn't automatically test against NumPy latest/mainline, but it does test NumPy alphas/pre-releases and provides feedback for these. Once a NumPy package becomes more generally available across a number of distribution mechanisms, support for that release of NumPy is added to Numba. As a result, released versions of Numba have explicit version constraints with respect to packages such as NumPy. As it's quite common for updates to e.g. NumPy to break something in Numba, Numba tries really hard to provide predicable failure modes (e.g. won't install or
RuntimeErrorfor unsupported NumPy being found).Do you think it'd be possible to
diffthe logs between last working and now? That might hint at the problem?Great, glad that's clearer, it's quite a "low level" problem.
keewis commentedon Nov 22, 2022
I just checked, and as far as I can tell the only difference are some I/O libraries (unrelated, I think) and the OS version. We use the
ubuntu-latesttag to run on github actions, and apparently that changed from20.04.5to22.04.1. Not sure if that should make a difference? Edit: the version of__glibcchanges as well:__glibc=2.31=0→__glibc=2.35=0Edit: For reference, here's the logs: passing (we have other errors, but they're definitely unrelated) and failing
stuartarchibald commentedon Nov 22, 2022
Thanks for checking @keewis. I'm going to make some guesses based on Numba internals... I think the following:
glibc,Pythonor Python C-API related as to get to the point of importingnumba.np.ufunc._internalNumba would have had to have imported other C extension modules that would have similarglibclinkage and C-API use and these evidently worked "OK" as errors were not raised.init_ufunc_dispatchfunction in_internal.c. NumPy has recently merged a change to help with Update ufunc loop signature resolution to use NumPy #22422 #8538 which may well be the cause of the problem if 2. is also correct.Numba relies on NumPy infrastructure for e.g. ufunc creation, and so there is a very tight coupling in this respect, between Numba and NumPy (the code is all in C and uses Python/NumPy C-API).
To debug and potentially fix the issue reported, maybe first try installing a supported released version of NumPy? If that fixes it, it narrows the problem down to what is suspected in the above.
Hope this helps.
max-sixty commentedon Nov 22, 2022
Our tests are still very much passing on the newest released versions of libraries; so this is only an issue with the versions from HEADs. I just tried installing
numpyfrom main — I get the same failure with numba 0.56.3 but it works with numba 0.56.4. I notice that's consistent with the declared dependencies ofnumba, so it seemsnumbais doing everything it should be...Possibly over at xarray, we should at least ensure we're on the latest numba for this test. I did a PR to do that earlier: pydata/xarray#7311 (review). Let us know if there's some pre-compiled version of dependencies (pydata/xarray#7311 (comment)), otherwise we'll just use
pip.Feel free to close, thanks for your attention @stuartarchibald !
keewis commentedon Nov 22, 2022
for me
numba=0.56.4fromconda-forgefails locally withnumpy=1.24.0.dev0+1120.gf30af6acd, so not sure what I'm doing wrong? @max-sixty, was that with thenumbahead?Edit: the install would be
pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple --pre "numpy==1.24.0.dev0+1120.gf30af6acd" --upgradeand
pipdoes indeed complain thatnumbarequiresnumpy<1.24but installs it anyways (as intended in this case, because we do actually want to test with the most recent version, even if that breaks something). So while point 2 from #8615 (comment) does not apply, point 3 may very well be the cause of the problem.max-sixty commentedon Nov 22, 2022
Redoing the test; I also get a failure with:
pip install .on numpy''s HEADSo I think my prior success with 0.56.4 must have been a mistake (I notice that pip reinstalls a lower version of numpy when installing a new version of numba, so that may have been it, mea culpa)
...so I'm not sure what we should do from Xarray's POV — I guess we can try running tests without
numba? But that misses some of the utility of these upstream tests.stuartarchibald commentedon Nov 23, 2022
I would anticipate that any issue, of the nature as described above, that is in 0.56.3 would also be in 0.56.4. The changes are here:
numba/CHANGE_LOG
Lines 1 to 14 in 3e96339
but in summary, it involved adding a couple of lines to fix a regression in
<array>.view()-like capabilities on the CUDA hardware target. Something that should not in any way impact the issue above as it's all in JIT code generation and specifically for CUDA users.[-]"SystemError: initialization of _internal failed without raising an exception"[/-][+]Error on import with numpy HEAD[/+]stuartarchibald commentedon Nov 23, 2022
I'm not sure what is best for the
Xarrayproject, however this information might help informing that decision.mainbranch has no restrictions on the version of NumPy, but it also doesn't track NumPyHEAD. The folks who maintain Numba do an upgrade of the supported NumPy version, often in a single patch, as pre-release packages become available for testing. I'll raise this issue with the other maintainers at the next triage meeting, but historically the view has been:HEAD.Hope this helps?
gmarkall commentedon Nov 23, 2022
The following quick-n-dirty patch gets around the
SystemErrorwith NumPymain:However, I have not tried much beyond that yet!
24 remaining items
Temporarily pin numpy to 1.23.5
Veda-73 commentedon Jan 16, 2023
I was having the same problem with the librosa library (The reason was that librosa was working with different versions of scipy and matplotlib), so I uninstalled numpy, matplotlib, and scipy, installed librosa first which installed its own compatible versions of libraries above and then I installed the necessary libraries. That seems to work for me.
ssvenoe commentedon Jan 18, 2023
Having this issue with
python=3.8.15, build: h4de0772_0_cpython, Channel: conda-forge
numba=0.56.4, build: pypi_0, channel: pypi
numpy=1.23.5, build: pypi_0, channel: pypi
stuartarchibald commentedon Jan 18, 2023
Thank you all for your comments/feedback on this issue. This issue seems to have diverged a little from the originally reported problem and so I'm closing this issue as resolved with some specific follow up issues to subscribe to if they are important to you:
HEAD.__init__.pynot catching incompatible NumPy version early enough #8718.inikishev commentedon Feb 11, 2023
what version of numpy should i install?
gmarkall commentedon Feb 14, 2023
If you're using the last released version of Numba (0.56.4 at time of writing), NumPy 1.18 - 1.23 are supported.
arijin commentedon Feb 17, 2023
Thanks. This help a lot. I reinstall numpy by "pip install numpy==1.23.0". Then, the error when "import numba" was solved.
pimiento commentedon Mar 25, 2023
Is it fixed in any version?
Limit version of numpy to <1.24
Add sourcepredict recipe (#40456)
chiiingky commentedon Apr 27, 2023
Hello everyone, the solutions posted here did not fix the problem for me. I tried numba v0.56.4 and v0.56.3 and both of these versions did not work with either numpy 1.23.0 or 1.24.0. I installed everything with conda-forge and I am using WSL. Any help would be greatly appreciated. Thank you!
Add sourcepredict recipe (bioconda#40456)
bugfix: update py-numba to 0.57.1
fyenne commentedon Aug 23, 2023
I fixed with
conda install cudatoolkiton a cpu only machine