|
| 1 | +# Base image with CUDA 12.6 and Ubuntu 24.04 (includes Python 3.12) |
| 2 | +FROM nvidia/cuda:12.6.0-devel-ubuntu24.04 |
| 3 | + |
| 4 | +# Set environment variables to non-interactive (prevents prompts during build) |
| 5 | +ENV DEBIAN_FRONTEND=noninteractive |
| 6 | +ENV PYTHONUNBUFFERED=1 |
| 7 | +ENV PYTHONDONTWRITEBYTECODE=1 |
| 8 | + |
| 9 | +# Set the working directory to /workspace (Standard for Runpod) |
| 10 | +WORKDIR /workspace |
| 11 | + |
| 12 | +# 1. Install System Dependencies |
| 13 | +# 'ffmpeg' is often required for video processing tasks in SAM3 |
| 14 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 15 | + git \ |
| 16 | + wget \ |
| 17 | + curl \ |
| 18 | + vim \ |
| 19 | + ffmpeg \ |
| 20 | + python3-pip \ |
| 21 | + python3-dev \ |
| 22 | + python3-venv \ |
| 23 | + && apt-get clean && rm -rf /var/lib/apt/lists/* |
| 24 | + |
| 25 | +# 2. Setup Python 3.12 as default 'python' |
| 26 | +# Ubuntu 24.04 ships with Python 3.12. We ensure 'python' points to it. |
| 27 | +RUN ln -s /usr/bin/python3 /usr/bin/python |
| 28 | + |
| 29 | +# 3. Install PyTorch 2.7+ with CUDA 12.6 support |
| 30 | +# Using the specific index URL provided in the SAM3 README |
| 31 | +RUN pip install --no-cache-dir --upgrade pip && \ |
| 32 | + pip install --no-cache-dir \ |
| 33 | + torch==2.7.0 \ |
| 34 | + torchvision \ |
| 35 | + torchaudio \ |
| 36 | + --index-url https://download.pytorch.org/whl/cu126 |
| 37 | + |
| 38 | +# 4. Clone and Install SAM3 |
| 39 | +# Cloning into /workspace/sam3 |
| 40 | +RUN git clone https://github.com/facebookresearch/sam3.git && \ |
| 41 | + cd sam3 && \ |
| 42 | + # Install the package in editable mode |
| 43 | + pip install -e . && \ |
| 44 | + # Install optional dependencies for notebooks and dev as recommended |
| 45 | + pip install -e ".[notebooks,dev,train]" |
| 46 | + |
| 47 | +# 5. (Optional) Install Jupyter for Runpod interactive mode |
| 48 | +RUN pip install jupyterlab |
| 49 | + |
| 50 | +# 6. Setup Entrypoint |
| 51 | +# Create a script to help with Hugging Face login (required for checkpoints) |
| 52 | +RUN echo '#!/bin/bash\n\ |
| 53 | +echo "----------------------------------------------------------------"\n\ |
| 54 | +echo "SAM3 Setup Complete."\n\ |
| 55 | +echo "NOTE: You must log in to Hugging Face to download checkpoints."\n\ |
| 56 | +echo "Run: huggingface-cli login"\n\ |
| 57 | +echo "Then follow the instructions in the README to download weights."\n\ |
| 58 | +echo "----------------------------------------------------------------"\n\ |
| 59 | +exec "$@"' > /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/entrypoint.sh |
| 60 | + |
| 61 | +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
| 62 | + |
| 63 | +# Default command: Start Jupyter Lab (common for Runpod) or sleep infinity |
| 64 | +CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--allow-root", "--no-browser"] |
0 commit comments