diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f9c6d9b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +FROM nvidia/cuda:12.6.0-runtime-ubuntu22.04 AS base + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + PORT=7865 \ + HF_HUB_ENABLE_HF_TRANSFER=1 \ + DEBIAN_FRONTEND=noninteractive + +# Install Python and system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3.10 \ + python3-pip \ + python3-venv \ + python3-dev \ + build-essential \ + git \ + curl \ + wget \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && ln -s /usr/bin/python3 /usr/bin/python + +# Create and activate virtual environment +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +# Create a non-root user to run the application +RUN useradd -m -u 1001 appuser + +# Set working directory +WORKDIR /app + +# Clone the repository +RUN git clone https://github.com/ace-step/ACE-Step.git . + +# Install specific PyTorch version compatible with CUDA 12.2 +RUN pip3 install --no-cache-dir --upgrade pip && \ + pip3 install --no-cache-dir hf_transfer peft && \ + pip3 install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu126 + +# Change ownership of app files to appuser +RUN chown -R appuser:appuser /app + +# Switch to non-root user +USER appuser + +# Expose the port the app runs on +EXPOSE 7865 + +VOLUME [ "/app/checkpoints", "/app/outputs", "/app/logs" ] + +# Set healthcheck +HEALTHCHECK --interval=60s --timeout=10s --start-period=5s --retries=5 \ + CMD curl -f http://localhost:7865/ || exit 1 + +# Command to run the application with GPU support +CMD ["python3", "app.py", "--server_name", "0.0.0.0", "--bf16", "true"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ece967f --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,39 @@ + +services: + &name ace-step: + build: + context: https://github.com/ace-step/ACE-Step.git + dockerfile: Dockerfile + container_name: *name + hostname: *name + stop_grace_period: 2s + ports: + - "7865:7865" + volumes: + - ace-step-checkpoints:/app/checkpoints + - ace-step-outputs:/app/outputs + - ace-step-logs:/app/exps/logs + # command: python app.py --server_name 0.0.0.0 --port 7865 --share False --bf16 True --torch_compile True --device-id 0 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:7865/"] + interval: 60s + timeout: 10s + retries: 30 + start_period: 3s + restart: unless-stopped + runtime: nvidia + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: ["compute", "utility", "graphics", "video"] + +volumes: + ace-step-checkpoints: + name: ace-step-checkpoints + ace-step-outputs: + name: ace-step-outputs + ace-step-logs: + name: ace-step-logs diff --git a/inference.ipynb b/inference.ipynb new file mode 100644 index 0000000..bdbaaf5 --- /dev/null +++ b/inference.ipynb @@ -0,0 +1,71 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "machine_shape": "hm", + "gpuType": "L4", + "authorship_tag": "ABX9TyMkPvEHcvZ84lF6ESOuPfMJ", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "cellView": "form", + "id": "EB_ztF9xch5s" + }, + "outputs": [], + "source": [ + "#@title Install and Download\n", + "!wget -O /content/mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py310_25.1.1-2-Linux-x86_64.sh\n", + "!chmod +x /content/mini.sh\n", + "!bash /content/mini.sh -b -f -p /usr/local\n", + "!conda install -q -y jupyter\n", + "!conda install -q -y google-colab -c conda-forge\n", + "!python -m ipykernel install --name \"py310\" --user\n", + "!git clone https://github.com/usamireko/ACE-Step\n", + "%cd /content/ACE-Step\n", + "!pip install -r requirements.txt\n", + "!pip install huggingface-hub numpy==1.26.0\n", + "!huggingface-cli download ACE-Step/ACE-Step-v1-3.5B --local-dir /content/ACE-Step/checkpoints --local-dir-use-symlinks False" + ] + }, + { + "cell_type": "code", + "source": [ + "#@title Run Gradio UI\n", + "bf16 = True # @param {\"type\":\"boolean\"}\n", + "\n", + "!python app.py --checkpoint_path ./checkpoints/ --port 7865 --device_id 0 --share true --bf16 {bf16}" + ], + "metadata": { + "cellView": "form", + "id": "0m835b3ZecQW" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file