Heroku Deployment Failed: OSError: libtorch_hip.so: cannot open shared object file: No such file or directory
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
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
Update:
Update:
Added torchaudio==0.13.1+cpu
to my requirements.txt and am now hitting a new error
File "/app/.heroku/python/lib/python3.8/site-packages/soundfile.py", line 142, in <module>
raise OSError('sndfile library not found')
OSError: sndfile library not found