- Qwen2 500M + WavTokenizer, torch cu128 GPU, 전용 venv 워커(8003) - 한국어 프리셋 4종(male/female), 속도·피치 librosa 후처리 - transformers 4.49로 torchvision 강제 import 회피, soundfile 저장 - scenema-audio는 VRAM 24GB+/Gemma12B 게이트로 8GB GPU에선 불가 → 미포함
97 lines
4.1 KiB
Docker
97 lines
4.1 KiB
Docker
# ---------- 빌더 단계 ----------
|
|
FROM python:3.11-slim AS builder
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
HF_HOME=/models \
|
|
NLTK_DATA=/models/nltk_data \
|
|
HF_HUB_DISABLE_TELEMETRY=1
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential git ffmpeg libsndfile1 curl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
RUN mkdir -p /models/nltk_data
|
|
|
|
# Blackwell(sm_120) 지원 torch cu128 휠
|
|
RUN pip install torch==2.11.0 torchaudio==2.11.0 \
|
|
--index-url https://download.pytorch.org/whl/cu128
|
|
|
|
COPY constraints.txt requirements.txt ./
|
|
RUN pip install -c constraints.txt -r requirements.txt
|
|
|
|
# MeloTTS(순수 파이썬) 벤더링
|
|
COPY vendor/melo /usr/local/lib/python3.11/site-packages/melo
|
|
|
|
# 한국어/영어 모델 사전 다운로드
|
|
COPY warmup.py ./
|
|
RUN python warmup.py
|
|
|
|
# 슬림화: 추론에 불필요한 패키지 제거
|
|
# - triton: torch.compile 전용(우리는 eager 추론이라 불필요)
|
|
# - gruut 미사용 언어(es/de/fr): 영어만 사용
|
|
RUN pip uninstall -y triton 2>/dev/null || true \
|
|
&& rm -rf /usr/local/lib/python3.11/site-packages/gruut_lang_es \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_de \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_fr \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_es-*.dist-info \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_de-*.dist-info \
|
|
/usr/local/lib/python3.11/site-packages/gruut_lang_fr-*.dist-info \
|
|
&& find /usr/local/lib/python3.11/site-packages -name "__pycache__" -type d -prune -exec rm -rf {} + 2>/dev/null || true
|
|
|
|
# 슬림화 후에도 한/영 모델이 정상 로드되는지 검증
|
|
RUN python -c "from melo.api import TTS; [TTS(l, device='cpu') for l in ('KR','EN','JP','ZH')]; print('slim import ok')"
|
|
|
|
# ---------- 런타임 단계 ----------
|
|
FROM python:3.11-slim AS runtime
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
HF_HOME=/models \
|
|
NLTK_DATA=/models/nltk_data \
|
|
HF_HUB_DISABLE_TELEMETRY=1
|
|
|
|
# 런타임 필수 라이브러리만 (컴파일러 툴체인 제외)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ffmpeg libsndfile1 libgomp1 ca-certificates rubberband-cli \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
COPY --from=builder /models /models
|
|
|
|
# ===== Supertonic 엔진 (자연스러운 한국어, MIT, ONNX, torch 불필요) =====
|
|
# 전용 venv 로 의존성 격리(메인 melo 스택의 librosa 0.9.1 과 충돌 방지).
|
|
COPY supertonic_worker /opt/supertonic_worker
|
|
RUN python -m venv /opt/supertonic-venv \
|
|
&& /opt/supertonic-venv/bin/pip install --no-cache-dir -r /opt/supertonic_worker/requirements.txt
|
|
|
|
# 모델 사전 다운로드(베이킹, ~260MB) — HF_HOME=/models 캐시에 저장
|
|
RUN HF_HOME=/models /opt/supertonic-venv/bin/python -c "from supertonic import TTS; TTS(auto_download=True)"
|
|
|
|
ENV SUPERTONIC_URL=http://127.0.0.1:8002
|
|
|
|
# ===== OuteTTS 엔진 (개인용/비상업, CC-BY-NC-4.0) =====
|
|
# Qwen2 500M LM + WavTokenizer 코덱. torch cu128 GPU. transformers 4.49(토치비전 회피).
|
|
COPY outetts_worker /opt/outetts_worker
|
|
RUN python -m venv /opt/oute-venv \
|
|
&& /opt/oute-venv/bin/pip install --no-cache-dir torch==2.11.0 torchaudio==2.11.0 \
|
|
--index-url https://download.pytorch.org/whl/cu128 \
|
|
&& /opt/oute-venv/bin/pip install --no-cache-dir -r /opt/outetts_worker/requirements.txt
|
|
RUN /opt/oute-venv/bin/pip uninstall -y torchvision 2>/dev/null || true
|
|
|
|
# 모델+코덱 사전 다운로드(베이킹) — 빌드 시엔 GPU 없이 CPU 로 로드
|
|
RUN HF_HOME=/models /opt/oute-venv/bin/python -c "import outetts; cfg=outetts.HFModelConfig_v1(model_path='OuteAI/OuteTTS-0.2-500M', language='ko'); outetts.InterfaceHF(model_version='0.2', cfg=cfg); print('oute warmup ok')"
|
|
|
|
ENV OUTETTS_URL=http://127.0.0.1:8003
|
|
|
|
COPY app ./app
|
|
COPY frontend ./frontend
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# MeloTTS(8788) + Supertonic(8002) + OuteTTS(8003) 동시 기동
|
|
EXPOSE 8788
|
|
CMD ["/entrypoint.sh"]
|