Spaces:
Runtime error
Runtime error
# Base image with Python 3.9 for app dependencies | |
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" | |
# Set working directory | |
WORKDIR /app | |
# Copy and install Python dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy application files | |
COPY --chown=user . /app | |
# Expose application port and set default command | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |
# Base image for CUDA support | |
FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04 as cuda | |
# Use noninteractive mode for apt-get | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install dependencies | |
RUN apt-get update && apt-get install -y \ | |
python3-opencv \ | |
python3-pip \ | |
ca-certificates \ | |
python3-dev \ | |
git \ | |
wget \ | |
sudo \ | |
ninja-build | |
# Link Python and Pip to default commands | |
RUN ln -sv /usr/bin/python3 /usr/bin/python && ln -sv /usr/bin/pip3 /usr/bin/pip | |
# Install Python packages | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
RUN pip install --user tensorboard cmake onnx | |
# Install fvcore | |
RUN pip install --user '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}" | |
# Install Detectron2 in editable mode | |
RUN pip install --user -e detectron2_repo | |
# Set fvcore cache directory | |
ENV FVCORE_CACHE="/tmp" | |
# Set working directory | |
WORKDIR /home/user/detectron2_repo | |