6

I am dockerising the flask application on windows10 machine.I get the below error after the docker run

RuntimeError: cannot cache function '__jaccard': no locator available for file '/usr/local/lib/python3.7/site-packages/librosa/util/matching.py'

The flask application runs fine locally on my machine.

i referred to kind of similar post: numba caching issue: cannot cache function / no locator available for file

i have added the user access permissions for the application in the Dockerfile.

1. Dockerfile

FROM python:3.7.3

RUN useradd admin

COPY . /app 

WORKDIR /app

RUN pip install -r "requirements.txt"

RUN chown -R admin:admin /app

RUN chmod 755 /app

USER admin

ENTRYPOINT ["python"]

CMD ["app.py"] 

2. requirements.txt

flask
tensorflow
flask_cors
uuid
librosa
numba
pysoundfile
numpy
cffi
requests
wave
h5py
pydub
werkzeug

3. Error log:

Traceback (most recent call last):
  File "app.py", line 6, in <module>
    import librosa
  File "/usr/local/lib/python3.7/site-packages/librosa/__init__.py", line 13, in <module>
    from . import core


  File "/usr/local/lib/python3.7/site-packages/librosa/core/__init__.py", line 114, in <module>
    from .time_frequency import *  # pylint: disable=wildcard-import


  File "/usr/local/lib/python3.7/site-packages/librosa/core/time_frequency.py", line 10, in <module>
    from ..util.exceptions import ParameterError


  File "/usr/local/lib/python3.7/site-packages/librosa/util/__init__.py", line 70, in <module>
    from .matching import *  # pylint: disable=wildcard-import


  File "/usr/local/lib/python3.7/site-packages/librosa/util/matching.py", line 16, in <module>
    @numba.jit(nopython=True, cache=True)
  File "/usr/local/lib/python3.7/site-packages/numba/decorators.py", line 179, in wrapper
    disp.enable_caching()


  File "/usr/local/lib/python3.7/site-packages/numba/dispatcher.py", line 571, in enable_caching
    self._cache = FunctionCache(self.py_func)

  File "/usr/local/lib/python3.7/site-packages/numba/caching.py", line 614, in __init__
    self._impl = self._impl_class(py_func)

  File "/usr/local/lib/python3.7/site-packages/numba/caching.py", line 349, in __init__
    "for file %r" % (qualname, source_path))


RuntimeError: cannot cache function '__jaccard': no locator available for file '/usr/local/lib/python3.7/site-packages/librosa/util/matching.py'
hongsy
  • 1,498
  • 1
  • 27
  • 39
sn1234
  • 103
  • 1
  • 8

2 Answers2

1

I've solved the problem by installing old version.

pip install librosa==0.6.0
0

I propose another answer: When I create my .yaml template for running something in the container, I set the following:

spec:
  template:
    spec:
      priorityClassName: <priority class>
      containers:
        - name: playaround
          image: <image_path>
          imagePullPolicy: "IfNotPresent"
          env:
            - name: NUMBA_CACHE_DIR
              value: "/misc/numba_cache" <-- choose any category that can be accessed from the container

This way, I set the environment variable, so numba has a location for the cache.


Edit: Try setting your environment variable in the script:

import os
os.environ[ 'NUMBA_CACHE_DIR' ] = '/tmp/'

(Note: Did not try, just posting for other users as a fallback. If somebody confirms its working, please comment.)

emil
  • 194
  • 1
  • 11