lolout1 commited on
Commit
bec92ad
·
1 Parent(s): 7ebe63e

updating Dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +49 -40
  2. requirements.txt +22 -17
Dockerfile CHANGED
@@ -1,73 +1,85 @@
1
- FROM python:3.8-slim
 
2
 
3
- # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  git \
6
  build-essential \
7
  cmake \
 
8
  python3-dev \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  libglib2.0-0 \
10
  libsm6 \
11
  libxext6 \
12
  libxrender-dev \
13
  libgomp1 \
14
  libgl1-mesa-glx \
15
- wget \
16
- curl \
17
- ninja-build \
18
- gcc-8 \
19
- g++-8 \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # Set gcc-8 as default (better compatibility with detectron2)
23
- RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
24
-
25
  # Create user
26
  RUN useradd -m -u 1000 user
27
 
28
  WORKDIR /app
29
 
30
- # Upgrade pip to a compatible version
31
  RUN pip install --upgrade "pip<24.1" setuptools wheel
32
 
33
- # Install PyTorch for Python 3.8
34
  RUN pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
35
 
36
- # Install compatible numpy and pillow
37
- RUN pip install numpy==1.21.6 pillow==9.5.0
38
-
39
- # Install detectron2 dependencies
40
  RUN pip install \
41
- cython \
 
42
  pycocotools \
43
  opencv-python==4.5.5.64 \
44
  scipy==1.7.3 \
45
- matplotlib==3.5.3 \
46
- cloudpickle \
47
- tabulate \
48
- tensorboard \
49
- yacs \
50
- termcolor \
51
- future \
52
- fvcore \
53
- iopath==0.1.9 \
54
- omegaconf==2.1.2 \
55
- hydra-core==1.1.2
56
 
57
- # Install detectron2 from source with Python 3.8 compatibility
58
- RUN git clone https://github.com/facebookresearch/detectron2.git && \
59
- cd detectron2 && \
60
- git checkout v0.6 && \
61
- python -m pip install -e . && \
62
- cd ..
63
 
64
- # Install additional dependencies
65
  RUN pip install \
66
  scikit-learn==1.0.2 \
67
  scikit-image==0.19.3 \
68
  gradio==3.35.2 \
69
  huggingface_hub==0.15.1 \
70
- tqdm
 
 
 
 
 
 
 
71
 
72
  # Switch to user
73
  USER user
@@ -76,7 +88,7 @@ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
76
  # Copy application
77
  COPY --chown=user:user . /app
78
 
79
- # Install additional requirements
80
  COPY --chown=user:user requirements.txt /app/requirements.txt
81
  RUN pip install --user --no-deps -r /app/requirements.txt || true
82
 
@@ -86,8 +98,5 @@ ENV FORCE_CUDA="0"
86
  ENV TORCH_CUDA_ARCH_LIST=""
87
  ENV PYTHONUNBUFFERED=1
88
 
89
- # Create necessary directories
90
- RUN mkdir -p /home/user/.cache
91
-
92
  EXPOSE 7860
93
  CMD ["python", "app.py"]
 
1
+ # Stage 1: Build detectron2
2
+ FROM python:3.8-slim as builder
3
 
 
4
  RUN apt-get update && apt-get install -y \
5
  git \
6
  build-essential \
7
  cmake \
8
+ ninja-build \
9
  python3-dev \
10
+ gcc-8 \
11
+ g++-8 \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Set gcc-8 as default
15
+ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
16
+
17
+ # Install build dependencies
18
+ RUN pip install --upgrade "pip<24.1" setuptools wheel
19
+ RUN pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
20
+ RUN pip install numpy==1.21.6 cython pycocotools
21
+
22
+ # Build detectron2 wheel
23
+ WORKDIR /tmp
24
+ RUN git clone https://github.com/facebookresearch/detectron2.git && \
25
+ cd detectron2 && \
26
+ git checkout v0.6 && \
27
+ python setup.py bdist_wheel && \
28
+ cp dist/*.whl /wheels/ || mkdir -p /wheels && \
29
+ pip wheel . --wheel-dir=/wheels
30
+
31
+ # Stage 2: Runtime image
32
+ FROM python:3.8-slim
33
+
34
+ # Install runtime dependencies only
35
+ RUN apt-get update && apt-get install -y \
36
  libglib2.0-0 \
37
  libsm6 \
38
  libxext6 \
39
  libxrender-dev \
40
  libgomp1 \
41
  libgl1-mesa-glx \
42
+ libgcc-s1 \
 
 
 
 
43
  && rm -rf /var/lib/apt/lists/*
44
 
 
 
 
45
  # Create user
46
  RUN useradd -m -u 1000 user
47
 
48
  WORKDIR /app
49
 
50
+ # Install Python packages
51
  RUN pip install --upgrade "pip<24.1" setuptools wheel
52
 
53
+ # Install PyTorch
54
  RUN pip install torch==1.13.1+cpu torchvision==0.14.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
55
 
56
+ # Install core dependencies
 
 
 
57
  RUN pip install \
58
+ numpy==1.21.6 \
59
+ pillow==9.5.0 \
60
  pycocotools \
61
  opencv-python==4.5.5.64 \
62
  scipy==1.7.3 \
63
+ matplotlib==3.5.3
 
 
 
 
 
 
 
 
 
 
64
 
65
+ # Copy and install detectron2 wheel from builder
66
+ COPY --from=builder /wheels/detectron2*.whl /tmp/
67
+ RUN pip install /tmp/detectron2*.whl && rm -f /tmp/detectron2*.whl
 
 
 
68
 
69
+ # Install remaining dependencies
70
  RUN pip install \
71
  scikit-learn==1.0.2 \
72
  scikit-image==0.19.3 \
73
  gradio==3.35.2 \
74
  huggingface_hub==0.15.1 \
75
+ tqdm \
76
+ iopath==0.1.9 \
77
+ omegaconf==2.1.2 \
78
+ hydra-core==1.1.2 \
79
+ tabulate \
80
+ tensorboard \
81
+ yacs \
82
+ termcolor
83
 
84
  # Switch to user
85
  USER user
 
88
  # Copy application
89
  COPY --chown=user:user . /app
90
 
91
+ # Install user requirements
92
  COPY --chown=user:user requirements.txt /app/requirements.txt
93
  RUN pip install --user --no-deps -r /app/requirements.txt || true
94
 
 
98
  ENV TORCH_CUDA_ARCH_LIST=""
99
  ENV PYTHONUNBUFFERED=1
100
 
 
 
 
101
  EXPOSE 7860
102
  CMD ["python", "app.py"]
requirements.txt CHANGED
@@ -1,19 +1,24 @@
1
- # Core dependencies (torch and detectron2 installed in Dockerfile)
2
- # Git dependencies
3
- git+https://github.com/cocodataset/panopticapi.git
4
- git+https://github.com/mcordts/cityscapesScripts.git
5
 
6
- # Additional dependencies
7
- imutils
8
- cython
9
- h5py
10
  timm==0.4.12
11
- einops
12
- gdown
13
- wget
14
- submitit
15
- shapely
16
- regex
17
- ftfy
18
- inflect
19
- diffdist
 
 
 
 
 
 
 
1
+ # Git dependencies compatible with Python 3.8
2
+ git+https://github.com/cocodataset/panopticapi.git@7bb4655
3
+ git+https://github.com/mcordts/cityscapesScripts.git@4f57ab6
 
4
 
5
+ # Core dependencies with Python 3.8 compatible versions
6
+ imutils==0.5.4
7
+ cython==0.29.35
8
+ h5py==3.7.0
9
  timm==0.4.12
10
+ einops==0.6.1
11
+ gdown==4.5.4
12
+ wget==3.2
13
+ submitit==1.4.5
14
+ shapely==1.8.5
15
+ regex==2022.10.31
16
+ ftfy==6.1.1
17
+ inflect==6.0.4
18
+
19
+ # Don't install these - handled in Dockerfile
20
+ # torch
21
+ # torchvision
22
+ # detectron2
23
+ # numpy
24
+ # pillow