pytorch / pytorch/pytorch.github.io

Heroku Deployment Failed: OSError: libtorch_hip.so: cannot open shared object file: No such file or directory

Open
#1,289 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
285
Forks
317
PR merge metrics
No merged PRs in 30d

Description

Any ideas on why my app won't deploy? Build is succeeding -- deploy is failing.

Here are my requirements.txt.

-f https://download.pytorch.org/whl/torch_stable.html
Django==4.1.4
djangorestframework==3.14.0
requests==2.28.1
whisper==1.0
django-cors-headers==3.13.0
psycopg2==2.9.5
gunicorn==20.1.0
dj-database-url>=1.0,<2.0
whitenoise>=6.0,<7.0
torch==1.13.1+cpu
speechbrain
pyannote.audio
pyannote.core

I'm using torch==1.13.1+cpu because torch==1.13.1 causes the compressed slug size on Heroku to be >500MB, which isn't allowed.

Full stack trace below:

/app/.heroku/python/lib/python3.8/site-packages/torchaudio/_internal/module_utils.py:99: UserWarning: Failed to import soundfile. 'soundfile' backend is not available.
  warnings.warn("Failed to import soundfile. 'soundfile' backend is not available.")
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 97, in handle
    self.check(databases=[database])
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 475, in check
    all_issues = checks.run_checks(
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/resolvers.py", line 494, in check
    for pattern in self.url_patterns:
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/podcast_project_django/urls.py", line 4, in <module>
    from . import views
  File "/app/podcast_project_django/views.py", line 12, in <module>
    from pyannote.audio.pipelines.speaker_verification import PretrainedSpeakerEmbedding
  File "/app/.heroku/python/lib/python3.8/site-packages/pyannote/audio/__init__.py", line 29, in <module>
    from .core.inference import Inference
  File "/app/.heroku/python/lib/python3.8/site-packages/pyannote/audio/core/inference.py", line 34, in <module>
    from pyannote.audio.core.io import AudioFile
  File "/app/.heroku/python/lib/python3.8/site-packages/pyannote/audio/core/io.py", line 38, in <module>
    import torchaudio
  File "/app/.heroku/python/lib/python3.8/site-packages/torchaudio/__init__.py", line 1, in <module>
    from torchaudio import (  # noqa: F401
  File "/app/.heroku/python/lib/python3.8/site-packages/torchaudio/_extension.py", line 135, in <module>
    _init_extension()
  File "/app/.heroku/python/lib/python3.8/site-packages/torchaudio/_extension.py", line 105, in _init_extension
    _load_lib("libtorchaudio")
  File "/app/.heroku/python/lib/python3.8/site-packages/torchaudio/_extension.py", line 52, in _load_lib
    torch.ops.load_library(path)
  File "/app/.heroku/python/lib/python3.8/site-packages/torch/_ops.py", line 573, in load_library
    ctypes.CDLL(path)
  File "/app/.heroku/python/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libtorch_hip.so: cannot open shared object file: No such file or directory

Edit: Here is the code block that I'm pretty sure is breaking the deploy:

model = whisper.load_model("small.en")
embedding_model = PretrainedSpeakerEmbedding(
    "speechbrain/spkrec-ecapa-voxceleb",
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
)

Comes from Dwarkesh Patel's app on huggingface: https://huggingface.co/spaces/dwarkesh/whisper-speaker-recognition/blob/main/app.py

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with requirements.txt and the import chain in podcast_project_django/urls.py and views.py, then reproduce the Heroku release's migrate step with the shown Python and PyTorch dependencies. Done would require a reproducible deployment change that removes the reported import failure, but the issue does not define a specific repository change.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python, pytorch
Domain
backend, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.