Spaces:
Runtime error
Runtime error
| # Stage 1: Base Python image | |
| FROM python:3.9 as base | |
| # Create a user and set environment variables | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| COPY --chown=user . $HOME/app | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy Python dependencies and install them | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir scikit-build | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| RUN pip install 'git+https://github.com/facebookresearch/detectron2.git' | |
| # Copy application files | |
| COPY --chown=user . /app | |
| # Stage 2: CUDA and Detectron2 | |
| # FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04 as cuda | |
| # Use noninteractive mode for apt-get | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install system dependencies | |
| USER root | |
| RUN apt-get update && apt-get clean | |
| RUN apt-get update && apt-get install -y --fix-missing \ | |
| python3-opencv \ | |
| python3-pip \ | |
| ca-certificates \ | |
| python3-dev \ | |
| git \ | |
| wget \ | |
| sudo \ | |
| ninja-build | |
| # Link Python and Pip commands | |
| # RUN ln -sv /usr/bin/python3 /usr/bin/python && ln -sv /usr/bin/pip3 /usr/bin/pip | |
| # # Copy dependencies from the base stage | |
| # COPY --from=base /home/user/.local /home/user/.local | |
| # COPY --from=base /app /app | |
| # Install additional Python packages | |
| RUN pip install --no-cache-dir scikit-build | |
| # RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| RUN pip install --no-cache-dir tensorboard cmake onnx | |
| RUN pip install --no-cache-dir 'git+https://github.com/facebookresearch/fvcore' | |
| # # Clone Detectron2 repository | |
| # RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo | |
| # # Set environment variables for Detectron2 | |
| # ENV FORCE_CUDA="1" | |
| # ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing" | |
| # ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}" | |
| # ENV FVCORE_CACHE="/tmp" | |
| # # Install Detectron2 in editable mode | |
| # RUN pip install --no-cache-dir -e detectron2_repo | |
| # Set the working directory and environment | |
| USER user | |
| ENV HOME=/home/user | |
| COPY --chown=user . $HOME/app | |
| WORKDIR $HOME/app | |
| # Expose application port and set default command | |
| RUN ls -a | |
| CMD ["python", "app.py"] | |