Spaces:
Runtime error
Runtime error
docker update
Browse files123456789101112131415161718192021222324252627282930313233343536373839# Stable combo: CUDA 11.8 + Torch 2.2.2 + Detectron2 prebuilt cu118 wheelsFROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04# System deps for rasterio/geopandas and build toolsRUN apt-get update && apt-get install -y \python3 python3-pip python3-dev \gdal-bin libgdal-dev \libgl1 ffmpeg \&& rm -rf /var/lib/apt/lists/*WORKDIR /appRUN python3 -m pip install --upgrade pip# --- Install PyTorch FIRST (CUDA 11.8 wheels)RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu118 \torch==2.2.2+cu118 torchvision==0.17.2+cu118# --- Detectron2 from PREBUILT wheels for torch 2.2 + cu118 (no compile)RUN pip install --no-cache-dir -f \https://dl.fbaipublicfiles.com/detectron2/wheels/cu118/torch2.2/index.html \detectron2==0.6# --- App deps (everything EXCEPT torch/detectron2)# Keep torch/detectron2 OUT of requirements.txt to avoid re-installCOPY requirements.txt /app/requirements.txtRUN sed -i '/torch/d;/detectron2/d' /app/requirements.txt && \pip install --no-cache-dir -r /app/requirements.txt# --- App codeCOPY . /app# Gradio envs (HF respects these)ENV GRADIO_SERVER_NAME=0.0.0.0ENV GRADIO_SERVER_PORT=7860# (Optional) Quick print of versions at container start for debugging# RUN python -c "import torch; print('Torch:', torch.__version__, 'CUDA:', torch.version.cuda)"CMD ["python3", "app.py"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051# CUDA 11.8 *devel* image so we have nvcc for compiling detectron2FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04# System deps: GDAL stack for rasterio/geopandas + build toolsRUN apt-get update && apt-get install -y \python3 python3-pip python3-dev \gdal-bin libgdal-dev \libgl1 ffmpeg \build-essential cmake ninja-build git pkg-config \&& rm -rf /var/lib/apt/lists/*WORKDIR /appRUN python3 -m pip install --upgrade pip# ---- Install PyTorch first (cu118) ----RUN pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu118 \torch==2.2.2+cu118 torchvision==0.17.2+cu118# Helpful build deps for detectron2RUN pip install --no-cache-dir wheel setuptools cython pybind11# ---- Build & install Detectron2 from source (v0.6) ----# v0.6 works well with torch 2.2.x; building avoids wheel-mismatch issuesRUN git clone --depth 1 --branch v0.6 https://github.com/facebookresearch/detectron2.git /opt/detectron2WORKDIR /opt/detectron2# USE_NINJA speeds up compile; if it causes issues, remove itENV FORCE_CUDA=1 TORCH_CUDA_ARCH_LIST="8.6;7.5;7.0" USE_NINJA=1RUN pip install --no-cache-dir -e .# ---- App deps (exclude torch/detectron2 here) ----WORKDIR /appCOPY requirements.txt /app/requirements.txt# remove any accidental torch/detectron2 lines to prevent reinstallRUN sed -i '/torch/d;/detectron2/d' /app/requirements.txt && \pip install --no-cache-dir -r /app/requirements.txt# ---- App code ----COPY . /app# Optional: print versions at start in logsRUN python3 - <<'PY'import torch, sysprint("Python:", sys.version)print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "CUDA avail:", torch.cuda.is_available())import detectron2, importlibprint("Detectron2:", detectron2.__version__)PYENV GRADIO_SERVER_NAME=0.0.0.0ENV GRADIO_SERVER_PORT=7860CMD ["python3", "app.py"]
Dockerfile+28-16