Skip to content

RuntimeError: cannot cache function #66

@WanderingStar

Description

@WanderingStar

I've been getting this error (and broken spectrogram links):

birdcage-birdcage_backend-1   | [2023-09-03 19:32:10,419] ERROR in app: Exception on /api/spectrogram/thumb/43626abc-3a49-465f-aa87-18513ff810fd.mp3.png [GET]
birdcage-birdcage_backend-1   | Traceback (most recent call last):
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2190, in wsgi_app
birdcage-birdcage_backend-1   |     response = self.full_dispatch_request()
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1486, in full_dispatch_request
birdcage-birdcage_backend-1   |     rv = self.handle_user_exception(e)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/flask_cors/extension.py", line 165, in wrapped_function
birdcage-birdcage_backend-1   |     return cors_after_request(app.make_response(f(*args, **kwargs)))
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
birdcage-birdcage_backend-1   |     rv = self.dispatch_request()
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
birdcage-birdcage_backend-1   |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
birdcage-birdcage_backend-1   |   File "/app/views/audio_files.py", line 79, in serve_thumb_spectrogram
birdcage-birdcage_backend-1   |     image_binary = create_spectrogram(audio_path, height=70)
birdcage-birdcage_backend-1   |   File "/app/views/audio_files.py", line 20, in create_spectrogram
birdcage-birdcage_backend-1   |     clip, sample_rate = librosa.load(fn_audio, sr=None)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/lazy_loader/__init__.py", line 77, in __getattr__
birdcage-birdcage_backend-1   |     attr = getattr(submod, name)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/lazy_loader/__init__.py", line 76, in __getattr__
birdcage-birdcage_backend-1   |     submod = importlib.import_module(submod_path)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
birdcage-birdcage_backend-1   |     return _bootstrap._gcd_import(name[level:], package, level)
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
birdcage-birdcage_backend-1   |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/librosa/core/audio.py", line 19, in <module>
birdcage-birdcage_backend-1   |     from .convert import frames_to_samples, time_to_samples
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/librosa/core/convert.py", line 7, in <module>
birdcage-birdcage_backend-1   |     from . import notation
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/librosa/core/notation.py", line 800, in <module>
birdcage-birdcage_backend-1   |     def __o_fold(d):
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/numba/core/decorators.py", line 234, in wrapper
birdcage-birdcage_backend-1   |     disp.enable_caching()
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/numba/core/dispatcher.py", line 863, in enable_caching
birdcage-birdcage_backend-1   |     self._cache = FunctionCache(self.py_func)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/numba/core/caching.py", line 601, in __init__
birdcage-birdcage_backend-1   |     self._impl = self._impl_class(py_func)
birdcage-birdcage_backend-1   |   File "/usr/local/lib/python3.10/site-packages/numba/core/caching.py", line 337, in __init__
birdcage-birdcage_backend-1   |     raise RuntimeError("cannot cache function %r: no locator available "
birdcage-birdcage_backend-1   | RuntimeError: cannot cache function '__o_fold': no locator available for file '/usr/local/lib/python3.10/site-packages/librosa/core/notation.py'

I've been able to fix it with this, based on this SO answer: https://stackoverflow.com/questions/59290386/runtimeerror-at-cannot-cache-function-shear-dense-no-locator-available-fo

  birdcage_backend:
    environment:
      NUMBA_CACHE_DIR: /tmp

But I'm not sure whether anything changed to cause it in the first place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions