Spaces:
Runtime error
Runtime error
docker
Browse files1212344566788910112 unmodified lines141516171819201718192022212224232425272627292829303132333534353736373938394041424445434644484945# ---- Base: CUDA 11.8 runtime (no compiler needed since we use wheels) ----FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04# ---------- GPU build: CUDA 12.1 + Torch 2.4.1 + Detectron2 0.6 ----------FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
ENV PYTHONUNBUFFERED=1 \ENV DEBIAN_FRONTEND=noninteractive \ PIP_NO_CACHE_DIR=1 \ DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1
# Minimal system deps (libgl1, ffmpeg often needed for cv2/visualization)# Minimal system depsRUN apt-get update && apt-get install -y --no-install-recommends \ python3 python3-pip python3-dev build-essential git \ libgl1 ffmpeg \2 unmodified linesWORKDIR /appRUN python3 -m pip install --upgrade pip
# ---- Install Torch/TV that match a Detectron2 0.6 prebuilt wheel (cu118) ----# NOTE: keep these exact versions to match the D2 wheel index below.RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu118 \ torch==2.1.2+cu118 torchvision==0.16.2+cu118# ---- Torch/TV matching D2 wheel (cu121 / torch 2.4) ----RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu121 \ torch==2.4.1+cu121 torchvision==0.19.1+cu121
# ---- Install Detectron2 0.6 from official prebuilt wheels (cu118 / torch2.1) ----# ---- Detectron2 0.6 prebuilt wheel (matches cu121 + torch2.4) ----RUN pip install --no-cache-dir -f \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu118/torch2.1/index.html \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu121/torch2.4/index.html \ detectron2==0.6
# ---- App dependencies (ensure requirements.txt does NOT reinstall torch/D2) ----# ---- Your deps (make sure requirements.txt DOES NOT list torch or detectron2) ----COPY requirements.txt /app/requirements.txtRUN sed -i '/torch/d;/detectron2/d' /app/requirements.txt && \RUN sed -i '/^torch/d;/^torchvision/d;/^detectron2/d' /app/requirements.txt && \ pip install --no-cache-dir -r /app/requirements.txt
# ---- App code ----COPY . /app
# Optional: log versions at build-time to verify the environment# Sanity printRUN python3 - <<'PY'import torch, sysimport sys, torchprint("Python:", sys.version)print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "CUDA avail:", torch.cuda.is_available())print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "cuda_is_available:", torch.cuda.is_available())import detectron2print("Detectron2:", detectron2.__version__)PY
# Gradio defaults for SpacesENV GRADIO_SERVER_NAME=0.0.0.0 \ENV GRADIO_SERVER_NAME=0.0.0.0 GRADIO_SERVER_PORT=7860 GRADIO_SERVER_PORT=7860EXPOSE 7860
# Start your app (adjust if your entrypoint is different)CMD ["python3", "app.py"]Dockerfile+16-21