Basic numpy.linalg functions not working

Hello,

I’ve been struggling with this all day and I can’t seem to figure out my issue.

Basic test code

import scipy
import numpy as np
import numba
from numba import njit

print("Numba version: ",numba.__version__)
print("Numpy version: ",np.__version__)
print("Scipy version: ",scipy.__version__)

@njit
def test(x):
    out = np.linalg.inv(x)
    return out        

x = np.eye(10, dtype='complex')
print(test(x))

Notes
I was able to open a remote server and have this run via the website (https://numba.pydata.org/), so I think it is something on my side. Additionally, this error pops up for almost any function from numpy.linalg, but not for numpy in general. I have updated all the libraries I can via pip, but it has me stuck on an old numba version. I do not think the older numba version should be the issue, since np.linalg.solve has been implemented since 0.27.0

Code output
Numba version: 0.51.2
Numpy version: 1.20.0
Scipy version: 1.6.0
Traceback (most recent call last):
File “/home/gregs/git_files/Resolvent_Python/Resolvent_Analysis/testing.py”, line 16, in
print(test(x))
File “/home/gregs/.local/lib/python3.9/site-packages/numba/core/dispatcher.py”, line 415, in _compile_for_args
error_rewrite(e, ‘typing’)
File “/home/gregs/.local/lib/python3.9/site-packages/numba/core/dispatcher.py”, line 358, in error_rewrite
reraise(type(e), e, None)
File “/home/gregs/.local/lib/python3.9/site-packages/numba/core/utils.py”, line 80, in reraise
raise value.with_traceback(tb)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<function inv at 0x7ff7c8c17160>) found for signature:

     >>> inv(array(complex128, 2d, C))
     
    There are 2 candidate implementations:
      - Of which 2 did not match due to:
      Overload in function 'inv_impl': File: numba/np/linalg.py: Line 833.
        With argument(s): '(array(complex128, 2d, C))':
       Rejected as the implementation raised a specific error:
         TypingError: Failed in nopython mode pipeline (step: nopython frontend)
       No implementation of function Function(<function _inv_err_handler at 0x7ff7bdf60550>) found for signature:
        
        >>> _inv_err_handler(int32)
        
       There are 2 candidate implementations:
             - Of which 2 did not match due to:
             Overload in function 'register_jitable.<locals>.wrap.<locals>.ov_wrap': File: numba/core/extending.py: Line 150.
               With argument(s): '(int32)':
              Rejected as the implementation raised a specific error:
                UnsupportedError: Failed in nopython mode pipeline (step: analyzing bytecode)
              Use of unsupported opcode (LOAD_ASSERTION_ERROR) found
              
              File "../../../.local/lib/python3.9/site-packages/numba/np/linalg.py", line 822:
              def _inv_err_handler(r):
                  <source elided>
                          fatal_error_func()
                          assert 0   # unreachable
                          ^
              
         raised from /home/gregs/.local/lib/python3.9/site-packages/numba/core/byteflow.py:269
       
       During: resolving callee type: Function(<function _inv_err_handler at 0x7ff7bdf60550>)
       During: typing of call at /home/gregs/.local/lib/python3.9/site-packages/numba/np/linalg.py (861)
       
       
       File "../../../.local/lib/python3.9/site-packages/numba/np/linalg.py", line 861:
           def inv_impl(a):
               <source elided>
               r = numba_xxgetrf(kind, n, n, acpy.ctypes, n, ipiv.ctypes)
               _inv_err_handler(r)
               ^

      raised from /home/gregs/.local/lib/python3.9/site-packages/numba/core/typeinfer.py:1071

    During: resolving callee type: Function(<function inv at 0x7ff7c8c17160>)
    During: typing of call at /home/gregs/git_files/Resolvent_Python/Resolvent_Analysis/testing.py (12)


    File "testing.py", line 12:
    def test(a):
        x = np.linalg.inv(a)
        ^

Hi @GregStroot

Numba doesn’t support Python 3.9 yet, in that traceback you can see:

 Use of unsupported opcode (LOAD_ASSERTION_ERROR) found

which is the root cause of the problem. I’m running Numba’s development branch locally and it has 3.9 support on it and the code above works fine.

If you would like to try out the latest development releases of Numba they are available via:

conda install -c numba/label/dev numba

(usual caveats about development versions apply!).

There’s also a Numba 0.53.0RC1 release scheduled for this week (which will have 3.9 support), it’ll be announced on this forum with instructions of how to get it if you want to wait for an actual release candidate to test.

An alternative to all this is to just use Python < 3.9 for now?

Hope this helps!?

Hi @stuartarchibald

Thanks for the quick reply. I thought it could be related to that – that’s one problem with rolling-release distros. This may be the time that I switch to a container environment of some kind.

I’ll wait for 0.53.0RC1 then and see how it goes.

Is there any reason that numba recommends conda or pip? I’ve heard better overall results about using pip on unix based systems

Thanks for the help