|
| 1 | +# ============================================================================= |
| 2 | +# OpenTranscribe Backend - Blackwell / DGX Spark Dockerfile |
| 3 | +# |
| 4 | +# Specialized image for NVIDIA Blackwell architecture (SM_121 / GB10) GPUs. |
| 5 | +# Based on NVIDIA's PyTorch container which bundles the correct CUDA 12.x |
| 6 | +# toolkit and ARM64-native torch builds. |
| 7 | +# |
| 8 | +# Key differences from Dockerfile.prod: |
| 9 | +# - Uses NVIDIA PyTorch base image (nvcr.io/nvidia/pytorch) instead of |
| 10 | +# python:3.13-slim to get ARM64 CUDA support |
| 11 | +# - Applies SM_121 -> SM_90 compatibility patches via scripts/blackwell_patches.py |
| 12 | +# - Pins huggingface_hub to avoid deprecated API calls in NVIDIA stack |
| 13 | +# - Sets CUDA_FORCE_PTX_JIT=1 for forward-compatible PTX execution |
| 14 | +# |
| 15 | +# Usage: |
| 16 | +# docker build -t opentranscribe-backend-blackwell -f Dockerfile.blackwell . |
| 17 | +# (Then reference in docker-compose.blackwell.yml) |
| 18 | +# ============================================================================= |
| 19 | + |
| 20 | +FROM nvcr.io/nvidia/pytorch:25.01-py3 |
| 21 | + |
| 22 | +LABEL org.opencontainers.image.title="OpenTranscribe Backend (Blackwell)" \ |
| 23 | + org.opencontainers.image.description="AI-powered transcription backend for NVIDIA Blackwell/DGX Spark" \ |
| 24 | + org.opencontainers.image.vendor="OpenTranscribe" \ |
| 25 | + org.opencontainers.image.authors="OpenTranscribe Contributors" \ |
| 26 | + org.opencontainers.image.licenses="AGPL-3.0" \ |
| 27 | + org.opencontainers.image.source="https://github.com/davidamacey/OpenTranscribe" |
| 28 | + |
| 29 | +WORKDIR /app |
| 30 | + |
| 31 | +# --------------------------------------------------------------------------- |
| 32 | +# Blackwell SM_121 compatibility environment variables |
| 33 | +# --------------------------------------------------------------------------- |
| 34 | +# CUDA_FORCE_PTX_JIT: Forces PTX JIT compilation for forward compatibility |
| 35 | +# when the installed CUDA toolkit doesn't know SM_121 natively. |
| 36 | +# TORCH_CUDA_ARCH_LIST: Tells PyTorch extensions to compile for SM_90 |
| 37 | +# (Hopper), which is binary-compatible with Blackwell via PTX fallback. |
| 38 | +ENV CUDA_FORCE_PTX_JIT=1 \ |
| 39 | + TORCH_CUDA_ARCH_LIST="9.0" \ |
| 40 | + PYTHONUNBUFFERED=1 \ |
| 41 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 42 | + PYTHONWARNINGS=ignore::UserWarning:pyannote.audio.core.io \ |
| 43 | + DEBIAN_FRONTEND=noninteractive |
| 44 | + |
| 45 | +# --------------------------------------------------------------------------- |
| 46 | +# System dependencies (runtime only) |
| 47 | +# --------------------------------------------------------------------------- |
| 48 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 49 | + curl \ |
| 50 | + ffmpeg \ |
| 51 | + libsndfile1 \ |
| 52 | + libimage-exiftool-perl \ |
| 53 | + libgomp1 \ |
| 54 | + && rm -rf /var/lib/apt/lists/* \ |
| 55 | + && apt-get clean |
| 56 | + |
| 57 | +# --------------------------------------------------------------------------- |
| 58 | +# Create directories for runtime and caches |
| 59 | +# --------------------------------------------------------------------------- |
| 60 | +# Note: The NVIDIA base image uses 'user' (UID 1000), not 'appuser'. |
| 61 | +# Cache volume mounts in docker-compose.blackwell.yml use /home/user/ paths. |
| 62 | +RUN mkdir -p /app/models /app/temp \ |
| 63 | + /home/user/.cache/huggingface \ |
| 64 | + /home/user/.cache/torch \ |
| 65 | + /home/user/.cache/nltk_data \ |
| 66 | + /home/user/.cache/sentence-transformers \ |
| 67 | + /home/user/.cache/yt-dlp |
| 68 | + |
| 69 | +# --------------------------------------------------------------------------- |
| 70 | +# Save NVIDIA-stack torch packages before pip installs can overwrite them |
| 71 | +# --------------------------------------------------------------------------- |
| 72 | +# The NVIDIA base image bundles a custom torch/torchaudio/torchvision built |
| 73 | +# against their CUDA toolkit. pip installs below might pull in PyPI versions |
| 74 | +# that lack the NVIDIA-specific patches. We save and restore. |
| 75 | +SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
| 76 | +RUN pip freeze | grep -iE '^(torch|torchaudio|torchvision)==' > /tmp/nvidia_torch_versions.txt |
| 77 | + |
| 78 | +# --------------------------------------------------------------------------- |
| 79 | +# Base Python tools |
| 80 | +# --------------------------------------------------------------------------- |
| 81 | +# hadolint ignore=DL3013 |
| 82 | +RUN pip install --no-cache-dir --upgrade pip setuptools wheel |
| 83 | + |
| 84 | +# --------------------------------------------------------------------------- |
| 85 | +# Install application dependencies |
| 86 | +# --------------------------------------------------------------------------- |
| 87 | +COPY requirements.txt . |
| 88 | +RUN pip install --no-cache-dir --no-warn-script-location -r requirements.txt |
| 89 | + |
| 90 | +# --------------------------------------------------------------------------- |
| 91 | +# Restore NVIDIA torch stack (overwrite any PyPI versions pulled by deps) |
| 92 | +# --------------------------------------------------------------------------- |
| 93 | +# hadolint ignore=DL3013,SC2046 |
| 94 | +RUN pip install --no-cache-dir --force-reinstall \ |
| 95 | + "$(cat /tmp/nvidia_torch_versions.txt | tr '\n' ' ')" |
| 96 | + |
| 97 | +# --------------------------------------------------------------------------- |
| 98 | +# Pin huggingface_hub for NVIDIA base image compatibility |
| 99 | +# --------------------------------------------------------------------------- |
| 100 | +# The NVIDIA PyTorch 25.01 base bundles libraries that still use the |
| 101 | +# deprecated `use_auth_token` parameter removed in huggingface_hub>=0.24. |
| 102 | +# This pin is Blackwell-specific and intentionally NOT in requirements.txt. |
| 103 | +RUN pip install --no-cache-dir "huggingface_hub==0.23.5" |
| 104 | + |
| 105 | +# --------------------------------------------------------------------------- |
| 106 | +# Install WhisperX (with --no-deps to preserve NVIDIA torch stack) |
| 107 | +# --------------------------------------------------------------------------- |
| 108 | +RUN pip install --no-cache-dir --no-deps "whisperx==3.8.1" |
| 109 | + |
| 110 | +# --------------------------------------------------------------------------- |
| 111 | +# Install PyAnnote fork with GPU optimizations |
| 112 | +# --------------------------------------------------------------------------- |
| 113 | +# Custom fork with vectorized chunking, adaptive batch size, TF32, CUDA |
| 114 | +# streams, and memory-safe batch indexing. |
| 115 | +RUN pip install --no-cache-dir --no-deps \ |
| 116 | + "pyannote.audio @ git+https://github.com/davidamacey/pyannote-audio.git@gpu-optimizations" |
| 117 | + |
| 118 | +# --------------------------------------------------------------------------- |
| 119 | +# Apply Blackwell SM_121 -> SM_90 compatibility patches |
| 120 | +# --------------------------------------------------------------------------- |
| 121 | +# Patches torch, torchaudio, and pyannote for SM_121 compatibility. |
| 122 | +# See scripts/blackwell_patches.py for details. |
| 123 | +COPY scripts/blackwell_patches.py scripts/blackwell_patches.py |
| 124 | +RUN python scripts/blackwell_patches.py |
| 125 | + |
| 126 | +# --------------------------------------------------------------------------- |
| 127 | +# Set cache environment variables |
| 128 | +# --------------------------------------------------------------------------- |
| 129 | +ENV HF_HOME=/home/user/.cache/huggingface \ |
| 130 | + TORCH_HOME=/home/user/.cache/torch \ |
| 131 | + NLTK_DATA=/home/user/.cache/nltk_data \ |
| 132 | + SENTENCE_TRANSFORMERS_HOME=/home/user/.cache/sentence-transformers |
| 133 | + |
| 134 | +# --------------------------------------------------------------------------- |
| 135 | +# Copy application code |
| 136 | +# --------------------------------------------------------------------------- |
| 137 | +COPY . . |
| 138 | + |
| 139 | +EXPOSE 8080 |
| 140 | + |
| 141 | +HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ |
| 142 | + CMD curl -f http://localhost:8080/health || exit 1 |
| 143 | + |
| 144 | +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"] |
0 commit comments