finsberg / ldrb

A software for assigning myocardial fiber orientations based on the Laplace Dirichlet Ruled-Based algorithm
http://finsberg.github.io/ldrb
GNU Lesser General Public License v3.0
22 stars 8 forks source link

TypingError: Failed in nopython mode pipeline (step: nopython frontend) - scipy #24

Closed Nobregaigor closed 2 years ago

Nobregaigor commented 2 years ago

Issue:

I was having issues executing any of the demo files. Whenever I ran:

fiber, sheet, sheet_normal = ldrb.dolfin_ldrb(
    mesh=mesh, fiber_space=fiber_space, ffun=ffun, markers=markers, **angles
)

I get the error described below, or a similar error related to TypingError: Failed in nopython mode pipeline (step: nopython frontend).

These are the methods I tried to install ldrb in plain miniconda enviroments (with no pre-installed packages) with python versions 3.8.12, 3.9.7, 3.10.

1) Directly installing ldrb using conda install -c conda-forge ldrb

2) First installing fenics using conda then using conda install -c conda-forge ldrb

3) First installing fenics using conda, then using python -m pip install ldrb

4) First installing fenics using conda, then using python -m pip install git+https://github.com/finsberg/ldrb.git

Possible reason:

It seems to be a compatibility issue with numba and maybe other package(s).

Solution:

After inspecting the error with Finsberg, installing scipy using conda install -c conda-forge scipy seems to have resolved the issue as numba requires the package for some computations.

Error message:

---------------------------------------------------------------------------
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
- Resolution failure for literal arguments:
No implementation of function Function(<function array_dot at 0x7f39b105d160>) found for signature:

 >>> array_dot(array(float64, 1d, C), array(float64, 1d, C))

There are 2 candidate implementations:
  - Of which 2 did not match due to:
  Overload in function 'array_dot': File: numba/np/arrayobj.py: Line 4891.
    With argument(s): '(array(float64, 1d, C), array(float64, 1d, C))':
   Rejected as the implementation raised a specific error:
     LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
   scipy 0.16+ is required for linear algebra

   File "../../../cenv/lib/python3.9/site-packages/numba/np/arrayobj.py", line 4894:
       def dot_impl(arr, other):
           return np.dot(arr, other)
           ^

   During: lowering "$10call_method.4 = call $4load_method.1(arr, other, func=$4load_method.1, args=[Var(arr, arrayobj.py:4894), Var(other, arrayobj.py:4894)], kws=(), vararg=None)" at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/numba/np/arrayobj.py (4894)
  raised from /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/numba/core/errors.py:751

- Resolution failure for non-literal arguments:
None

During: resolving callee type: BoundFunction((<class 'numba.core.types.npytypes.Array'>, 'dot') for array(float64, 1d, C))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (317)

File "../../../cenv/lib/python3.9/site-packages/ldrb/calculus.py", line 317:
def axis(u: np.ndarray, v: np.ndarray) -> np.ndarray:
    <source elided>
    e2 = normalize(v)
    e2 -= e1.dot(e2) * e1
    ^

During: resolving callee type: type(CPUDispatcher(<function axis at 0x7f39b0adf430>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (275)

During: resolving callee type: type(CPUDispatcher(<function axis at 0x7f39b0adf430>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (280)

During: resolving callee type: type(CPUDispatcher(<function axis at 0x7f39b0adf430>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (287)

During: resolving callee type: type(CPUDispatcher(<function axis at 0x7f39b0adf430>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (275)

File "../../../cenv/lib/python3.9/site-packages/ldrb/calculus.py", line 275:
def system_at_dof(
    <source elided>
    if lv > tol:
        Q_lv = axis(grad_ab, -1 * grad_lv)
        ^

During: resolving callee type: type(CPUDispatcher(<function system_at_dof at 0x7f39b0ad8f70>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (453)

During: resolving callee type: type(CPUDispatcher(<function system_at_dof at 0x7f39b0ad8f70>))
During: typing of call at /home/igornobrega/Project-Heart/cenv/lib/python3.9/site-packages/ldrb/calculus.py (453)

File "../../../cenv/lib/python3.9/site-packages/ldrb/calculus.py", line 453:
def _compute_fiber_sheet_system(
    <source elided>

        Q_fiber = system_at_dof(
        ^