Spaces:
Running on Zero
Running on Zero
[Admin maintenance] Support new ZeroGPU hardware
#3
by multimodalart HF Staff - opened
app.py
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import yaml
|
|
@@ -9,6 +30,36 @@ import torch.nn.functional as F
|
|
| 9 |
import librosa
|
| 10 |
from tqdm import tqdm
|
| 11 |
from diffusers import DDIMScheduler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
from solospeech.model.solospeech.conditioners import SoloSpeech_TSE
|
| 13 |
# from solospeech.model.solospeech.conditioners import SoloSpeech_TSR
|
| 14 |
from solospeech.scripts.solospeech.utils import save_audio
|
|
|
|
| 1 |
+
# The `solospeech` package (installed from git in requirements.txt) hard-pins
|
| 2 |
+
# torch==2.4.1/torchaudio==2.4.1/torchvision==0.19.1 in its own setup.py.
|
| 3 |
+
# Those wheels predate NVIDIA Blackwell (sm_120) and have no compatible CUDA
|
| 4 |
+
# kernels, causing `RuntimeError: CUDA error: no kernel image is available
|
| 5 |
+
# for execution on the device` on ZeroGPU's current hardware. We can't loosen
|
| 6 |
+
# solospeech's pin from here (it's an upstream dependency, and requirements.txt
|
| 7 |
+
# is resolved in a single pip invocation where an explicit newer torch pin
|
| 8 |
+
# conflicts with solospeech's exact pin). So: let the build install whatever
|
| 9 |
+
# solospeech demands, then upgrade torch to a Blackwell-compatible build at
|
| 10 |
+
# container startup, before torch (or anything importing it) is loaded.
|
| 11 |
+
import subprocess
|
| 12 |
+
import sys
|
| 13 |
+
|
| 14 |
+
subprocess.run(
|
| 15 |
+
[
|
| 16 |
+
sys.executable, "-m", "pip", "install", "--no-cache-dir",
|
| 17 |
+
"torch==2.8.0", "torchaudio==2.8.0", "torchvision==0.23.0",
|
| 18 |
+
],
|
| 19 |
+
check=True,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
import gradio as gr
|
| 23 |
import spaces
|
| 24 |
import yaml
|
|
|
|
| 30 |
import librosa
|
| 31 |
from tqdm import tqdm
|
| 32 |
from diffusers import DDIMScheduler
|
| 33 |
+
|
| 34 |
+
# speechbrain==1.0.2 (pinned transitively by the `solospeech` package) still
|
| 35 |
+
# calls huggingface_hub.hf_hub_download(..., use_auth_token=...). Newer
|
| 36 |
+
# huggingface_hub releases dropped that kwarg in favor of `token`, which
|
| 37 |
+
# raises `TypeError: hf_hub_download() got an unexpected keyword argument
|
| 38 |
+
# 'use_auth_token'`. Shim it here so old callers keep working.
|
| 39 |
+
import huggingface_hub
|
| 40 |
+
|
| 41 |
+
_orig_hf_hub_download = huggingface_hub.hf_hub_download
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _hf_hub_download_compat(*args, **kwargs):
|
| 45 |
+
if "use_auth_token" in kwargs:
|
| 46 |
+
kwargs["token"] = kwargs.pop("use_auth_token")
|
| 47 |
+
return _orig_hf_hub_download(*args, **kwargs)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
huggingface_hub.hf_hub_download = _hf_hub_download_compat
|
| 51 |
+
|
| 52 |
+
# speechbrain's fetch() catches `requests.exceptions.HTTPError` to gracefully
|
| 53 |
+
# skip an optional file (e.g. the default "custom.py") that doesn't exist in
|
| 54 |
+
# a model repo. Newer huggingface_hub raises `RemoteEntryNotFoundError`
|
| 55 |
+
# (built on httpx, not requests) for the same 404, so that except clause no
|
| 56 |
+
# longer matches and the error propagates instead of being swallowed. Widen
|
| 57 |
+
# the caught exception type so the old graceful-skip behavior still works.
|
| 58 |
+
import speechbrain.utils.fetching as _sb_fetching
|
| 59 |
+
from huggingface_hub.errors import HfHubHTTPError as _HfHubHTTPError
|
| 60 |
+
|
| 61 |
+
_sb_fetching.HTTPError = (_sb_fetching.HTTPError, _HfHubHTTPError)
|
| 62 |
+
|
| 63 |
from solospeech.model.solospeech.conditioners import SoloSpeech_TSE
|
| 64 |
# from solospeech.model.solospeech.conditioners import SoloSpeech_TSR
|
| 65 |
from solospeech.scripts.solospeech.utils import save_audio
|