-
Notifications
You must be signed in to change notification settings - Fork 17
Add Docker configuration for Maya1 TTS deployment #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hasithdd
wants to merge
3
commits into
MayaResearch:master
Choose a base branch
from
hasithdd:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: Docker Build and Publish | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "master" ] | ||
| # Publish semver tags as releases. | ||
| tags: [ 'v*.*.*' ] | ||
| pull_request: | ||
| branches: [ "master" ] | ||
|
|
||
| env: | ||
| # Use docker.io for Docker Hub if empty | ||
| REGISTRY: ghcr.io | ||
| # github.repository as <account>/<repo> | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| # This is used to complete the identity challenge | ||
| # with sigstore/fulcio when running outside of PRs. | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| # Install the cosign tool except on PR | ||
| # https://github.com/sigstore/cosign-installer | ||
| - name: Install cosign | ||
| if: github.event_name != 'pull_request' | ||
| uses: sigstore/cosign-installer@v3.5.0 | ||
| with: | ||
| cosign-release: 'v2.2.4' | ||
|
|
||
| # Set up Buildx | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| # Login against a Docker registry except on PR | ||
| # https://github.com/docker/login-action | ||
| - 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 }} | ||
|
|
||
| # Extract metadata (tags, labels) for Docker | ||
| # https://github.com/docker/metadata-action | ||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
| type=ref,event=branch | ||
| type=ref,event=tag | ||
| type=sha | ||
|
|
||
| # Build and push Docker image with Buildx (don't push on PR) | ||
| # https://github.com/docker/build-push-action | ||
| - name: Build and push Docker image | ||
| id: build-and-push | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| file: docker/Dockerfile | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| # Sign the resulting Docker image digest except on PRs. | ||
| # This will only write to the public Rekor transparency log when the Docker | ||
| # repository is public to avoid leaking data. If you would like to publish | ||
| # transparency data even for private images, pass --force to cosign below. | ||
| # https://github.com/sigstore/cosign | ||
| - name: Sign the published Docker image | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| env: | ||
| TAGS: ${{ steps.meta.outputs.tags }} | ||
| DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
| run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| .git | ||
| .gitignore | ||
| venv/ | ||
| __pycache__/ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .DS_Store | ||
| logs/ | ||
| hf_space/ | ||
| docker/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Use NVIDIA CUDA base image | ||
| FROM nvidia/cuda:12.8.0-devel-ubuntu22.04 | ||
|
|
||
| # Set environment variables | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV PYTHONUNBUFFERED=1 | ||
| ENV PYTHONDONTWRITEBYTECODE=1 | ||
| ENV TORCH_CUDA_ARCH_LIST="8.0;8.6;8.9;9.0" | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| python3 \ | ||
| python3-pip \ | ||
| python3-dev \ | ||
| git \ | ||
| libsndfile1 \ | ||
| ffmpeg \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create symbolic link for python | ||
| RUN ln -s /usr/bin/python3 /usr/bin/python | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy requirements file | ||
| COPY requirements.txt . | ||
|
|
||
| # Install Python dependencies | ||
| RUN pip install --no-cache-dir --upgrade pip && \ | ||
| pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| # Copy application code | ||
| COPY maya1/ maya1/ | ||
| COPY server.sh . | ||
| COPY samples.txt . | ||
| COPY README.md . | ||
|
|
||
| # Create logs directory | ||
| RUN mkdir -p logs | ||
|
|
||
| # Expose the API port | ||
| EXPOSE 8000 | ||
|
|
||
| # Health check | ||
| HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | ||
| CMD curl -f http://localhost:8000/health || exit 1 | ||
|
|
||
| # Run the application | ||
| CMD ["uvicorn", "maya1.api_v2:app", "--host", "0.0.0.0", "--port", "8000"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Maya1 TTS Docker Deployment | ||
|
|
||
| This directory contains the configuration for deploying Maya1 TTS using Docker. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Docker installed | ||
| - NVIDIA GPU with drivers installed | ||
| - NVIDIA Container Toolkit installed (for GPU support) | ||
|
|
||
| ## Files | ||
|
|
||
| - `Dockerfile`: The Docker image definition. | ||
| - `docker-gpu.sh`: Helper script to build and run the container with GPU support. | ||
| - `.dockerignore`: Specifies files to exclude from the build context. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Using the helper script | ||
|
|
||
| Run the following command from the project root or the `docker` directory: | ||
|
|
||
| ```bash | ||
| ./docker/docker-gpu.sh | ||
| ``` | ||
|
|
||
| This will: | ||
| 1. Build the Docker image `maya1-tts`. | ||
| 2. Run the container with all available GPUs. | ||
| 3. Expose the API on port 8000. | ||
|
|
||
| ### Manual Build and Run | ||
|
|
||
| **Build:** | ||
|
|
||
| ```bash | ||
| docker build -t maya1-tts -f docker/Dockerfile . | ||
| ``` | ||
|
|
||
| **Run:** | ||
|
|
||
| ```bash | ||
| docker run --gpus all --ipc=host -p 8000:8000 maya1-tts | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - The container uses `nvidia/cuda:12.1.1-devel-ubuntu22.04` as the base image. | ||
| - It installs Python 3.10 and all dependencies from `requirements.txt`. | ||
| - The API is available at `http://localhost:8000`. | ||
| - Health check is available at `http://localhost:8000/health`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Colors | ||
| GREEN='\033[0;32m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' | ||
|
|
||
| echo -e "${BLUE}Building Maya1 TTS Docker Image...${NC}" | ||
|
|
||
| # Navigate to project root | ||
| cd "$(dirname "$0")/.." | ||
|
|
||
| # Build the image | ||
| docker build -t maya1-tts -f docker/Dockerfile . | ||
|
|
||
| if [ $? -eq 0 ]; then | ||
| echo -e "${GREEN}Build successful!${NC}" | ||
| echo -e "${BLUE}Starting container with GPU support...${NC}" | ||
|
|
||
| # Run the container | ||
| docker run --gpus all \ | ||
| --ipc=host \ | ||
| -p 8000:8000 \ | ||
| --name maya1-tts-server \ | ||
| --rm \ | ||
| -it \ | ||
| maya1-tts | ||
| else | ||
| echo -e "\033[0;31mBuild failed!${NC}" | ||
| exit 1 | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.