Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3e0d5ff
rebase after restructure
manascb1344 Feb 22, 2025
05a15a7
fix github action
manascb1344 Feb 22, 2025
62180e0
Update CI workflow to trigger on all branches and PRs
manascb1344 Feb 22, 2025
bd147bd
add git to docker file
manascb1344 Feb 22, 2025
dc06f91
feat: Add FastAPI main application with Zonos TTS endpoints
manascb1344 Feb 22, 2025
33de2ef
feat: Enhance TTS sampling with advanced configuration parameters
manascb1344 Feb 22, 2025
dfa0ac0
refactor: Improve TTS service and API configuration
manascb1344 Feb 22, 2025
aab9af0
feat: Expose advanced TTS sampling parameters in API request
manascb1344 Feb 22, 2025
7d57b33
fix: Optimize Dockerfile and extend TTS generation time
manascb1344 Feb 22, 2025
20fd5df
update Dockerfile
manascb1344 Feb 22, 2025
f7f835f
feat: Enhance CI workflow and update Dockerfile for improved dependen…
manascb1344 Feb 23, 2025
034995b
feat: Update CI workflow to improve Docker image naming and tagging l…
manascb1344 Feb 23, 2025
d2a8bbc
feat: Enhance CI workflow and Dockerfile for improved caching and dep…
manascb1344 Feb 23, 2025
5ef7e78
feat: Update Dockerfile to use PyTorch base image and improve depende…
manascb1344 Feb 23, 2025
9d06d3d
feat: Update Dockerfile to use --system flag for pip installations an…
manascb1344 Feb 23, 2025
c69f24b
fix: Correct pip command in Dockerfile for GPU dependencies installation
manascb1344 Feb 23, 2025
3b543fd
fix: Update pip command in Dockerfile to remove 'uv' prefix for GPU d…
manascb1344 Feb 23, 2025
38d345a
feat: Update Dockerfile to use an older PyTorch base image and improv…
manascb1344 Feb 23, 2025
75d6e79
Make Non-Interactive
manascb1344 Feb 23, 2025
81f64e4
fix: Refactor Dockerfile to streamline pip installation commands and …
manascb1344 Feb 23, 2025
1e37b58
refactor: Optimize Dockerfile dependency installation with granular R…
manascb1344 Feb 23, 2025
8a16882
ci: Add disk space cleanup step to GitHub Actions workflow
manascb1344 Feb 23, 2025
09e4629
refactor: Optimize Dockerfile with improved package installation and …
manascb1344 Feb 23, 2025
f9e95a5
refactor: Update Dockerfile to streamline Zonos installation and impr…
manascb1344 Feb 24, 2025
71acbc8
refactor: Optimize Docker configuration for Zonos API deployment
manascb1344 Feb 25, 2025
06cf62e
feat: Add comprehensive logging to Zonos TTS API main module
manascb1344 Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions .env.example

This file was deleted.

133 changes: 95 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,106 @@
name: CI/CD
name: Build and Push Docker Image

on:
push:
branches: [ '*' ]
branches:
- '**'
tags: ["v*.*.*"]
pull_request:
branches: [ '*' ]
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CACHE_FROM: type=registry,ref=${{ github.repository }}:buildcache
CACHE_TO: type=registry,ref=${{ github.repository }}:buildcache,mode=max

jobs:
docker:
free-disk-space:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

build-and-push:
runs-on: ubuntu-latest
needs: free-disk-space # Ensure this job runs after freeing disk space
permissions:
contents: read
packages: write

id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=sha,format=long
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:latest

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Cache Python dependencies
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

# Set image name based on branch
- name: Set image name and tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# For main branch
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,format=short,prefix=,enable=${{ github.ref == 'refs/heads/main' }}
# For other branches
type=raw,value=dev-latest,enable=${{ github.ref != 'refs/heads/main' }}
type=sha,format=short,prefix=dev-,enable=${{ github.ref != 'refs/heads/main' }}
# For tags
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
platforms: linux/amd64
build-args: |
BUILDKIT_INLINE_CACHE=1
24 changes: 0 additions & 24 deletions .pre-commit-config.yaml

This file was deleted.

44 changes: 0 additions & 44 deletions CHANGELOG.md

This file was deleted.

108 changes: 58 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,60 +1,68 @@
FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel
FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-devel

WORKDIR /app
# Set Zonos working directory
WORKDIR /app/zonos

# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
# System packages
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
espeak-ng \
curl \
git \
espeak-ng \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install uv
RUN pip install -U uv

# Copy application code and submodules
COPY . .

# Initialize and update submodules
RUN git submodule update --init --recursive --remote

# Install dependencies with optimizations
RUN uv pip install --system --no-build-isolation -e .[compile] && \
# Install flash-attention and other optimizations
pip install --no-build-isolation \
flash-attn \
mamba-ssm \
causal-conv1d

# Create a non-root user and setup directories
RUN useradd -m -u 1000 appuser && \
mkdir -p /home/appuser/.cache/huggingface && \
chown -R appuser:appuser /home/appuser/.cache && \
mkdir -p /app/uploads && \
chown -R appuser:appuser /app

USER appuser

# Set environment variables
ENV PORT=8000
ENV WORKERS=4
ENV MODEL_TYPE="Transformer"
ENV MODEL_CACHE_DIR="/home/appuser/.cache/huggingface"
ENV PYTHONUNBUFFERED=1
# CUDA optimization settings
ENV CUDA_LAUNCH_BLOCKING=0
# Install uv package manager
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install --no-cache-dir uv

# Clone Zonos directly into working directory
RUN git clone --depth 1 https://github.com/Zyphra/Zonos.git . \
&& git submodule update --init --recursive

# Copy dependency specs and application code
COPY requirements.txt pyproject.toml ./
COPY app/ app/

# Install basic Python dependencies first
RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install --system -r requirements.txt -e .[compile]

# Install Flash Attention with specific compiler flags
ENV TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6+PTX"
ENV CUDA_HOME="/usr/local/cuda"
ENV MAX_JOBS=4
ENV FLASH_ATTENTION_FORCE_BUILD=1
RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install --system --no-build-isolation \
git+https://github.com/Dao-AILab/[email protected]

# Install remaining ML dependencies
RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install --system --no-build-isolation \
mamba-ssm==2.2.4 \
causal-conv1d==1.5.0.post8

RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install --system \
kanjize>=1.5.0 \
inflect>=7.5.0 \
&& rm -rf /root/.cache/pip/*

RUN --mount=type=cache,target=/root/.cache/pip \
uv pip install --system \
phonemizer>=3.3.0 \
sudachidict-full>=20241021 \
sudachipy>=0.6.10 \
&& rm -rf /root/.cache/pip/*

# Expose the port
EXPOSE $PORT
# Copy application code last
COPY app/ app/

# Add healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:$PORT/health || exit 1
# Environment variables
ENV PYTHONPATH=/app:/app/zonos \
USE_GPU=true \
PYTHONUNBUFFERED=1

# Run the application with Gunicorn
CMD ["sh", "-c", "gunicorn main:app --workers $WORKERS --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT --timeout 300 --worker-tmp-dir /dev/shm"]
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Loading
Loading