File size: 2,415 Bytes
690571a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | # Use a lightweight Python base
FROM python:3.10-slim
# Prevent interactive prompts & speed up Python
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
TOKENIZERS_PARALLELISM=false
# Set work directory
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
wget \
libopenblas-dev \
libomp-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first (for Docker caching)
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Hugging Face tools
RUN pip install --no-cache-dir huggingface-hub accelerate
# Install additional dependencies
RUN pip install --no-cache-dir outetts uroman
# Clone yarngpt repository
RUN git clone https://github.com/saheedniyi02/yarngpt.git /tmp/yarngpt && \
pip install --no-cache-dir /tmp/yarngpt && \
rm -rf /tmp/yarngpt
# Set Hugging Face cache inside container (persistent, not /tmp)
ENV HF_HOME=/models/huggingface
ENV TRANSFORMERS_CACHE=/models/huggingface
ENV HUGGINGFACE_HUB_CACHE=/models/huggingface
ENV HF_HUB_CACHE=/models/huggingface
# Create cache dir and models directory
RUN mkdir -p /models/huggingface && \
mkdir -p /code/models
# Pre-download model at build time (YarnGPT2 model)
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='saheedniyi/YarnGPT2')"
# Preload tokenizer (avoid runtime delays)
RUN python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('saheedniyi/YarnGPT2', use_fast=True)"
# Download wavtokenizer configuration file
RUN wget -O /code/models/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml \
https://huggingface.co/novateur/WavTokenizer-medium-speech-75token/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml
# Note: Checkpoint file must be downloaded separately or mounted as volume
# The checkpoint is large and may not download during build
RUN echo "Note: wavtokenizer_large_speech_320_24k.ckpt must be provided separately"
# Copy project files
COPY . .
# Expose FastAPI port
EXPOSE 8000
# Run FastAPI app with uvicorn (2 workers for better concurrency)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]
|