AOT compiling: cannot find -lnpymath

Hoi zame,
I am trying to compile

import numpy as np
import numba as nb
from numba.pycc import CC

cc = CC('barrier')

@nb.jit(nopython=True, nogil=True, parallel=False, cache=True)
@cc.export('barrier_touch', 'i4(f8[:], f8, f8)')
def barrier_touch(vec, low=-np.inf, high=np.inf):
    return -1

@cc.export("barrier_touch_mat", "void(f8[:,:], i4[:], f8, f8)")
def barrier_touch_matrix(mat, temp, low=-np.inf, high=np.inf):
    for row_index in nb.prange(mat.shape[0]):
        temp[row_index] = int(barrier_touch(mat[row_index], low=low, high=high))

This is done in setup.py via

ext_modules=[cc.distutils_extension()],

The compiler complains with

/opt/conda/compiler_compat/ld: cannot find -lnpymath

I am happy to drown you in more output of the logger but I think that’s for now the core message.

Hi @tschm, I am unable to reproduce locally. The code compiles for me:

(base) root@692f3cb483e6:/.../...# pip install .
Processing /.../...
Building wheels for collected packages: foo
  Building wheel for foo (setup.py) ... done
  Created wheel for foo: filename=foo-0.0.0-cp38-cp38-linux_x86_64.whl size=43829 sha256=b075a925c8a56a193bd51d9d53b386b4e01931b71793bc67e706c0f59559af3b
  Stored in directory: /tmp/pip-ephem-wheel-cache-ifwmdo6z/wheels/36/d9/33/e35aa526d2829302e917fdbc85e0dc02107f402c906e4eab31
Successfully built foo
Installing collected packages: foo
Successfully installed foo-0.0.0

(base) root@692f3cb483e6:/.../...# python
Python 3.8.3 (default, Jul  2 2020, 16:21:59) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.barrier_touch
CPUDispatcher(<function barrier_touch at 0x7f6810d15700>)

This is on, Debian 10, Python 3.8.3, and Numba 0.53.0rc1.

Can you please provide more detail on the error message and also let us know which OS, Python version, and Numba version you’re running?

1 Like

Hi @ryanchien, Many thanks for looking into my problem.

For your amusement I am trying to describe my embarrassing mistake. I was doing all of this in an internal docker image which is essentially

FROM jupyter/scipy-notebook:aec555e49be6 as builder

# Install Python 3 packages
RUN conda install -c conda-forge \
    plotly  \
    python-kaleido \
    cvxpy \
    nbconvert && \
    conda clean -afy && \
    find /opt/conda/ -follow -type f -name '*.a' -delete && \
    find /opt/conda/ -follow -type f -name '*.pyc' -delete

I was too successful in reducing the size of the image and cleaned the *.a files needed for the compiler. The construction of those docker images is done in a different project and I was not aware of this until I tried the scipy Jupyter image directly to produce a repeatable problem for you.
Again, many thanks for looking into this.

That is funny, glad you found the fix!