4.41.3a
Browse files- Dockerfile +3 -11
Dockerfile
CHANGED
|
@@ -14,15 +14,12 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|
| 14 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 15 |
TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6+PTX" \
|
| 16 |
CUDA_VISIBLE_DEVICES="0" \
|
| 17 |
-
# Threads (fixes libgomp warnings)
|
| 18 |
OMP_NUM_THREADS=4 \
|
| 19 |
OPENBLAS_NUM_THREADS=1 \
|
| 20 |
MKL_NUM_THREADS=1 \
|
| 21 |
NUMEXPR_NUM_THREADS=1 \
|
| 22 |
-
# Caches inside repo volume (stable on Spaces)
|
| 23 |
HF_HOME=/home/user/app/.hf \
|
| 24 |
TORCH_HOME=/home/user/app/.torch \
|
| 25 |
-
# Gradio port coherency (HF proxy)
|
| 26 |
GRADIO_SERVER_PORT=7860
|
| 27 |
|
| 28 |
# ---- Non-root user ----
|
|
@@ -43,7 +40,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 43 |
RUN python3 -m pip install --upgrade pip setuptools wheel
|
| 44 |
|
| 45 |
# ---- Install PyTorch (CUDA 12.1 wheels) ----
|
| 46 |
-
# Using the official cu121 wheel index keeps runtime aligned with base image
|
| 47 |
RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
|
| 48 |
torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
|
| 49 |
&& python3 - <<'PY'
|
|
@@ -63,7 +59,6 @@ PY
|
|
| 63 |
COPY --chown=user:user requirements.txt ./
|
| 64 |
|
| 65 |
# ---- Install remaining Python deps ----
|
| 66 |
-
# (requirements.txt contains gradio==4.41.3 and libs; NOT the SAM2 repo)
|
| 67 |
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
| 68 |
|
| 69 |
# ---- MatAnyone (pip install from repo with retry) ----
|
|
@@ -77,7 +72,6 @@ RUN echo "Installing MatAnyone..." && \
|
|
| 77 |
COPY --chown=user:user . .
|
| 78 |
|
| 79 |
# ---- SAM2 from source (editable) ----
|
| 80 |
-
# Keep SAM2 out of requirements.txt to avoid duplicate installs
|
| 81 |
RUN echo "Installing SAM2 (editable)..." && \
|
| 82 |
git clone --depth=1 https://github.com/facebookresearch/segment-anything-2.git third_party/sam2 && \
|
| 83 |
cd third_party/sam2 && python3 -m pip install --no-cache-dir -e .
|
|
@@ -100,11 +94,9 @@ RUN mkdir -p /home/user/app/checkpoints /home/user/app/.hf /home/user/app/.torch
|
|
| 100 |
find /home/user/app -type f -exec chmod 644 {} \; && \
|
| 101 |
chmod +x /home/user/app/ui.py || true
|
| 102 |
|
| 103 |
-
# ---- Healthcheck (
|
| 104 |
-
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD
|
| 105 |
-
import torch,
|
| 106 |
-
print(f"torch {torch.__version__} | cuda {getattr(torch.version,'cuda',None)} | ok={torch.cuda.is_available()}")
|
| 107 |
-
PY
|
| 108 |
|
| 109 |
# ---- Runtime ----
|
| 110 |
USER user
|
|
|
|
| 14 |
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
| 15 |
TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6+PTX" \
|
| 16 |
CUDA_VISIBLE_DEVICES="0" \
|
|
|
|
| 17 |
OMP_NUM_THREADS=4 \
|
| 18 |
OPENBLAS_NUM_THREADS=1 \
|
| 19 |
MKL_NUM_THREADS=1 \
|
| 20 |
NUMEXPR_NUM_THREADS=1 \
|
|
|
|
| 21 |
HF_HOME=/home/user/app/.hf \
|
| 22 |
TORCH_HOME=/home/user/app/.torch \
|
|
|
|
| 23 |
GRADIO_SERVER_PORT=7860
|
| 24 |
|
| 25 |
# ---- Non-root user ----
|
|
|
|
| 40 |
RUN python3 -m pip install --upgrade pip setuptools wheel
|
| 41 |
|
| 42 |
# ---- Install PyTorch (CUDA 12.1 wheels) ----
|
|
|
|
| 43 |
RUN python3 -m pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \
|
| 44 |
torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
|
| 45 |
&& python3 - <<'PY'
|
|
|
|
| 59 |
COPY --chown=user:user requirements.txt ./
|
| 60 |
|
| 61 |
# ---- Install remaining Python deps ----
|
|
|
|
| 62 |
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
| 63 |
|
| 64 |
# ---- MatAnyone (pip install from repo with retry) ----
|
|
|
|
| 72 |
COPY --chown=user:user . .
|
| 73 |
|
| 74 |
# ---- SAM2 from source (editable) ----
|
|
|
|
| 75 |
RUN echo "Installing SAM2 (editable)..." && \
|
| 76 |
git clone --depth=1 https://github.com/facebookresearch/segment-anything-2.git third_party/sam2 && \
|
| 77 |
cd third_party/sam2 && python3 -m pip install --no-cache-dir -e .
|
|
|
|
| 94 |
find /home/user/app -type f -exec chmod 644 {} \; && \
|
| 95 |
chmod +x /home/user/app/ui.py || true
|
| 96 |
|
| 97 |
+
# ---- Healthcheck (use exec-form, no heredoc) ----
|
| 98 |
+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD \
|
| 99 |
+
["python3","-c","import torch; print('torch', torch.__version__, '| cuda', getattr(torch.version,'cuda',None), '| ok=', torch.cuda.is_available())"]
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# ---- Runtime ----
|
| 102 |
USER user
|