Spaces:
Sleeping
Sleeping
| # -runtime is enough: Supertonic 3 is pure ONNX Runtime inference (no CUDA extensions to build). | |
| FROM nvidia/cuda:12.9.0-runtime-ubuntu24.04 | |
| # Avoid interactive prompts during package installation | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install Python and system dependencies (libsndfile1 + ffmpeg for audio I/O). | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 \ | |
| python3-pip \ | |
| python3-dev \ | |
| git \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set Python alias (Ubuntu 24.04 ships Python 3.12) | |
| RUN ln -sf /usr/bin/python3 /usr/bin/python | |
| # Allow pip to install packages system-wide in the container (PEP 668) | |
| ENV PIP_BREAK_SYSTEM_PACKAGES=1 | |
| WORKDIR /app | |
| # Upgrade pip so it fetches prebuilt manylinux wheels. Debian-installed pip has no RECORD | |
| # file and cannot be uninstalled, hence --ignore-installed. | |
| RUN pip install --no-cache-dir --upgrade --ignore-installed pip setuptools wheel | |
| # No torch needed: inference is pure ONNX Runtime. | |
| # onnxruntime-gpu 1.23.x ships CUDA 12.x builds (matches the 12.9 base) but needs cuDNN 9, | |
| # which the -runtime base image does NOT include -> pull cuDNN 9 from pip and expose it via | |
| # LD_LIBRARY_PATH (cuBLAS etc. are already in the CUDA runtime image). The CUDA EP falls | |
| # back to CPUExecutionProvider if anything is missing (run_eval.py prints active providers). | |
| # Pin onnxruntime to the version the upstream repo pins (1.23.1); `onnx` is used by | |
| # run_eval.py to count model parameters from the graph initializers. | |
| RUN pip install --no-cache-dir \ | |
| onnxruntime-gpu==1.23.0 \ | |
| nvidia-cudnn-cu12 \ | |
| "numpy>=1.26.0" \ | |
| soundfile \ | |
| onnx | |
| ENV LD_LIBRARY_PATH=/usr/local/lib/python3.12/dist-packages/nvidia/cudnn/lib:${LD_LIBRARY_PATH} | |
| # Clone the reference implementation: run_eval.py imports the ONNX pipeline | |
| # (TextToSpeech.batch, load_onnx_all, load_voice_style, ...) from py/helper.py. | |
| # helper.py itself only needs numpy + onnxruntime (librosa/PyYAML in the repo's | |
| # requirements.txt are for other examples and are not imported). | |
| RUN git clone https://github.com/supertone-inc/supertonic.git /opt/supertonic | |
| ENV SUPERTONIC_HELPER_DIR=/opt/supertonic/py | |
| # datasets + tqdm for the eval loop; huggingface_hub to bake the weights below. | |
| RUN pip install --no-cache-dir datasets tqdm huggingface_hub | |
| # Bake the Supertonic 3 assets (~400 MB: 4 ONNX graphs + tts.json + unicode_indexer.json | |
| # + M1-M5/F1-F5 voice-style JSONs). Ungated, so no HF token needed. | |
| RUN python3 -c "from huggingface_hub import snapshot_download; snapshot_download('Supertone/supertonic-3', local_dir='/opt/supertonic3', allow_patterns=['onnx/*', 'voice_styles/*', 'config.json'])" | |
| # Copy the full repository | |
| COPY . /app | |
| # Default entrypoint | |
| ENTRYPOINT ["bash"] | |
| # Keep-alive CMD so the Space runtime stays healthy; `docker run` overrides it. | |
| EXPOSE 7860 | |
| CMD ["-c", "python3 -m http.server 7860"] | |