Spaces:
Runtime error
Runtime error
docker
Browse files2 unmodified lines3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051522 unmodified linesENV DEBIAN_FRONTEND=noninteractive \PIP_NO_CACHE_DIR=1 \PYTHONUNBUFFERED=1 \OMP_NUM_THREADS=1 \MPLCONFIGDIR=/tmp/matplotlib# System deps (Python 3.8 on Ubuntu 20.04)RUN apt-get update && apt-get install -y --no-install-recommends \python3 python3-pip python3-dev build-essential git \libgl1 ffmpeg \&& rm -rf /var/lib/apt/lists/*# Matplotlib writable cache dirRUN mkdir -p /tmp/matplotlibWORKDIR /appRUN python3 -m pip install --upgrade pip# ----- Pin Pillow < 10 first (Detectron2 0.6 expects Image.LINEAR/BILINEAR names) -----RUN python3 -m pip install --no-cache-dir "Pillow<10"# ----- PyTorch 1.10.2 + cu113 (matches D2 0.6 prebuilt wheels) -----RUN python3 -m pip install --no-cache-dir -f https://download.pytorch.org/whl/cu113/torch_stable.html \torch==1.10.2+cu113 torchvision==0.11.3+cu113# ----- Detectron2 0.6 prebuilt wheel for torch1.10 + cu113 -----RUN python3 -m pip install --no-cache-dir -f \https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html \detectron2==0.6# ----- Your deps (ensure they don't re-pin torch/torchvision/detectron2/Pillow) -----COPY requirements.txt /app/requirements.txtRUN sed -i '/^[Pp]illow/d;/^torch/d;/^torchvision/d;/^detectron2/d' /app/requirements.txt && \python3 -m pip install --no-cache-dir -r /app/requirements.txt# ----- App code + sanity print -----COPY . /appRUN python3 - <<'PY'import sys, torchprint("Python:", sys.version)print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "cuda_available:", torch.cuda.is_available())import detectron2print("Detectron2:", detectron2.__version__)PY# Gradio server envENV GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860EXPOSE 7860CMD ["python3", "app.py"]2 unmodified lines3456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869702 unmodified linesENV DEBIAN_FRONTEND=noninteractive \PIP_NO_CACHE_DIR=1 \PYTHONUNBUFFERED=1# Create a non-root user (uid 1000 matches Spaces default)RUN useradd -m -u 1000 -s /bin/bash user# System depsRUN apt-get update && apt-get install -y --no-install-recommends \python3 python3-pip python3-dev build-essential git libgl1 ffmpeg \&& rm -rf /var/lib/apt/lists/*WORKDIR /appRUN python3 -m pip install --upgrade pip# Pillow < 10 (Detectron2 0.6 references PIL.Image.LINEAR which Pillow 10 removed)RUN python3 -m pip install --no-cache-dir "Pillow<10"# PyTorch 1.10.2 + cu113 (matches Detectron2 0.6 prebuilt wheels)RUN python3 -m pip install --no-cache-dir -f https://download.pytorch.org/whl/cu113/torch_stable.html \torch==1.10.2+cu113 torchvision==0.11.3+cu113# Detectron2 0.6 prebuilt for torch1.10 + cu113RUN python3 -m pip install --no-cache-dir -f \https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html \detectron2==0.6# Your deps (do NOT re-pin torch/torchvision/detectron2/Pillow)COPY requirements.txt /app/requirements.txtRUN sed -i '/^[Pp]illow/d;/^torch/d;/^torchvision/d;/^detectron2/d' /app/requirements.txt && \python3 -m pip install --no-cache-dir -r /app/requirements.txt# App codeCOPY . /app# Writable dirs + perms for the non-root userRUN mkdir -p /app/weights \&& mkdir -p /home/user/.config/matplotlib \&& mkdir -p /home/user/.cache/huggingface \&& chown -R 1000:1000 /app /home/user \&& chmod -R 775 /app \&& chmod -R 777 /home/user/.config/matplotlib# Runtime envENV HF_HOME=/home/user/.cache/huggingface \MPLCONFIGDIR=/home/user/.config/matplotlib \GRADIO_SERVER_NAME=0.0.0.0 \GRADIO_SERVER_PORT=7860# Hard-override OMP thread count at runtime to avoid libgomp crashes on SpacesRUN printf '#!/usr/bin/env bash\nexport OMP_NUM_THREADS=1\nexec "$@"\n' > /usr/local/bin/entry.sh \&& chmod +x /usr/local/bin/entry.shUSER 1000:1000# Quick sanity as non-root (optional)RUN python3 - <<'PY'import os, torch, detectron2, PILprint("uid:", os.getuid())print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "CUDA avail:", torch.cuda.is_available())print("Detectron2:", detectron2.__version__)print("Pillow:", PIL.__version__)PYEXPOSE 7860ENTRYPOINT ["/usr/local/bin/entry.sh"]CMD ["python3", "app.py"]
Dockerfile+38-20