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