reidddd commited on
Commit
f5f3936
·
1 Parent(s): 323ee2f

update import detectron2

Browse files
Files changed (1) hide show
  1. Dockerfile +40 -15
Dockerfile CHANGED
@@ -1,38 +1,63 @@
 
 
1
 
2
- FROM python:3.9
3
-
4
  RUN useradd -m -u 1000 user
5
  USER user
6
  ENV PATH="/home/user/.local/bin:$PATH"
7
 
 
8
  WORKDIR /app
9
 
 
10
  COPY --chown=user ./requirements.txt requirements.txt
11
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
 
 
13
  COPY --chown=user . /app
 
 
14
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
15
- FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04
16
 
17
- ENV DEBIAN_FRONTEND noninteractive
18
- RUN apt-get update && apt-get install -y \
19
- python3-opencv python3-pip ca-certificates python3-dev git wget sudo ninja-build
20
- RUN ln -sv /usr/bin/python3 /usr/bin/python
21
 
22
- RUN pip install --user tensorboard cmake onnx
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  RUN pip install --user 'git+https://github.com/facebookresearch/fvcore'
 
 
24
  RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo
 
 
25
  ENV FORCE_CUDA="1"
26
  ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing"
27
  ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"
28
 
 
29
  RUN pip install --user -e detectron2_repo
 
 
30
  ENV FVCORE_CACHE="/tmp"
31
- WORKDIR /home/user/detectron2_repo
32
 
33
- # run detectron2 under user "user":
34
- # wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg
35
- # python3 demo/demo.py \
36
- #--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
37
- #--input input.jpg --output outputs/ \
38
- #--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
 
1
+ # Base image with Python 3.9 for app dependencies
2
+ FROM python:3.9 as base
3
 
4
+ # Create a user and set environment variables
 
5
  RUN useradd -m -u 1000 user
6
  USER user
7
  ENV PATH="/home/user/.local/bin:$PATH"
8
 
9
+ # Set working directory
10
  WORKDIR /app
11
 
12
+ # Copy and install Python dependencies
13
  COPY --chown=user ./requirements.txt requirements.txt
14
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
 
16
+ # Copy application files
17
  COPY --chown=user . /app
18
+
19
+ # Expose application port and set default command
20
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
21
 
22
+ # Base image for CUDA support
23
+ FROM nvidia/cuda:11.1.1-cudnn8-devel-ubuntu18.04 as cuda
 
 
24
 
25
+ # Use noninteractive mode for apt-get
26
+ ENV DEBIAN_FRONTEND=noninteractive
27
+
28
+ # Install dependencies
29
+ RUN apt-get update && apt-get install -y \
30
+ python3-opencv \
31
+ python3-pip \
32
+ ca-certificates \
33
+ python3-dev \
34
+ git \
35
+ wget \
36
+ sudo \
37
+ ninja-build
38
+
39
+ # Link Python and Pip to default commands
40
+ RUN ln -sv /usr/bin/python3 /usr/bin/python && ln -sv /usr/bin/pip3 /usr/bin/pip
41
+
42
+ # Install Python packages
43
+ RUN pip install --user tensorboard cmake onnx
44
+
45
+ # Install fvcore
46
  RUN pip install --user 'git+https://github.com/facebookresearch/fvcore'
47
+
48
+ # Clone Detectron2 repository
49
  RUN git clone https://github.com/facebookresearch/detectron2 detectron2_repo
50
+
51
+ # Set environment variables for Detectron2
52
  ENV FORCE_CUDA="1"
53
  ARG TORCH_CUDA_ARCH_LIST="Kepler;Kepler+Tesla;Maxwell;Maxwell+Tegra;Pascal;Volta;Turing"
54
  ENV TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST}"
55
 
56
+ # Install Detectron2 in editable mode
57
  RUN pip install --user -e detectron2_repo
58
+
59
+ # Set fvcore cache directory
60
  ENV FVCORE_CACHE="/tmp"
 
61
 
62
+ # Set working directory
63
+ WORKDIR /home/user/detectron2_repo