Spaces:
Paused
Paused
| # MusePlayer Backend Dockerfile | |
| # Optimized for Hugging Face Spaces with GPU support | |
| # ----------------------------------------------- | |
| FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04 | |
| WORKDIR /app | |
| # Prevent interactive prompts and ensure consistent Python behavior | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| HF_HOME=/tmp/huggingface_cache \ | |
| TRANSFORMERS_CACHE=/tmp/huggingface_cache \ | |
| PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True \ | |
| GRADIO_ANALYTICS_ENABLED=0 | |
| # Install system dependencies | |
| # ffmpeg + libsndfile1 are required for audio processing | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.10 \ | |
| python3-pip \ | |
| python3-dev \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| libsndfile1-dev \ | |
| git \ | |
| wget \ | |
| curl \ | |
| build-essential \ | |
| ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && ln -sf /usr/bin/python3.10 /usr/bin/python \ | |
| && ln -sf /usr/bin/python3.10 /usr/bin/python3 | |
| # Upgrade pip and install build tools | |
| RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel | |
| # Install PyTorch with CUDA 12.1 support explicitly | |
| # We pin this before requirements.txt to avoid CPU-only torch installation | |
| RUN python -m pip install --no-cache-dir \ | |
| torch==2.5.1 \ | |
| torchvision==0.20.1 \ | |
| torchaudio==2.5.1 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # Copy and install Python dependencies | |
| # Note: torch is excluded from requirements.txt since it's pre-installed above | |
| COPY requirements.txt . | |
| RUN python -m pip install --no-cache-dir -r requirements.txt | |
| # Create directories for model cache and generated outputs | |
| # Hugging Face Spaces allows ephemeral disk; /tmp is safe and fast | |
| RUN mkdir -p /tmp/huggingface_cache /tmp/museplayer_outputs && \ | |
| chmod -R 777 /tmp/huggingface_cache /tmp/museplayer_outputs | |
| # Copy the backend application | |
| COPY app.py . | |
| # Hugging Face Spaces exposes this port by default | |
| EXPOSE 7860 | |
| # Preload the ACE-Step model on startup so first requests are fast | |
| ENV PRELOAD_MODEL=1 | |
| # Start the FastAPI + Gradio server | |
| CMD ["python", "app.py"] | |