lolout1 commited on
Commit
e5fdbf1
·
1 Parent(s): f9277d5

updating dockerfile and dependencies for optimal hf deployment

Browse files
Files changed (2) hide show
  1. Dockerfile +27 -29
  2. requirements.txt +5 -53
Dockerfile CHANGED
@@ -12,62 +12,60 @@ RUN apt-get update && apt-get install -y \
12
  libxrender-dev \
13
  libgomp1 \
14
  libgl1-mesa-glx \
15
- libgtk2.0-dev \
16
  wget \
17
  curl \
18
- unzip \
19
- ffmpeg \
20
- libopencv-dev \
21
- ninja-build \
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
- # Create user
25
  RUN useradd -m -u 1000 user
26
 
27
- # Install Python dependencies in correct order
 
 
 
 
28
  RUN pip install --upgrade pip setuptools wheel
29
 
30
- # Install sympy FIRST (required by torch)
31
- RUN pip install sympy
32
 
33
- # Install PyTorch CPU version
34
  RUN pip install torch==2.0.1+cpu torchvision==0.15.2+cpu --index-url https://download.pytorch.org/whl/cpu
35
 
36
- # Install detectron2 from pre-built wheel (more reliable)
 
 
 
37
  RUN pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch2.0/index.html
38
 
39
- # Install other dependencies
40
  RUN pip install \
41
- numpy>=1.23.0,<2.0.0 \
42
  opencv-python \
43
  scipy \
44
  scikit-learn \
 
 
45
  gradio \
46
- huggingface_hub
 
47
 
48
  # Switch to user
49
  USER user
50
  ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
51
- WORKDIR $HOME/app
 
 
 
 
 
52
 
53
  # Set environment for CPU
54
  ENV CUDA_VISIBLE_DEVICES=""
55
  ENV FORCE_CUDA="0"
56
  ENV TORCH_CUDA_ARCH_LIST=""
57
 
58
- # Copy requirements and install remaining dependencies
59
- COPY --chown=user:user requirements.txt .
60
- RUN pip install --user --no-cache-dir -r requirements.txt
61
-
62
- # Copy app files
63
- COPY --chown=user:user . .
64
-
65
- # Clone and setup OneFormer if needed
66
- RUN if [ ! -d "oneformer" ]; then \
67
- git clone https://github.com/SHI-Labs/OneFormer.git oneformer && \
68
- cd oneformer && \
69
- pip install --user -e . ; \
70
- fi
71
-
72
  EXPOSE 7860
 
 
73
  CMD ["python", "gradio_test.py"]
 
12
  libxrender-dev \
13
  libgomp1 \
14
  libgl1-mesa-glx \
 
15
  wget \
16
  curl \
 
 
 
 
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Create user (required by Hugging Face)
20
  RUN useradd -m -u 1000 user
21
 
22
+ # Set working directory
23
+ WORKDIR /app
24
+
25
+ # Install Python dependencies in the correct order
26
+ # First, upgrade pip and install essential tools
27
  RUN pip install --upgrade pip setuptools wheel
28
 
29
+ # Install PyTorch dependencies FIRST
30
+ RUN pip install sympy filelock jinja2 networkx requests typing-extensions
31
 
32
+ # Install PyTorch CPU version WITH dependencies
33
  RUN pip install torch==2.0.1+cpu torchvision==0.15.2+cpu --index-url https://download.pytorch.org/whl/cpu
34
 
35
+ # Install numpy and pillow (specific versions for compatibility)
36
+ RUN pip install numpy==1.24.3 pillow==10.0.0
37
+
38
+ # Install detectron2 from pre-built wheel (much more reliable than building from source)
39
  RUN pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch2.0/index.html
40
 
41
+ # Install other core dependencies
42
  RUN pip install \
 
43
  opencv-python \
44
  scipy \
45
  scikit-learn \
46
+ scikit-image \
47
+ matplotlib \
48
  gradio \
49
+ huggingface_hub \
50
+ tqdm
51
 
52
  # Switch to user
53
  USER user
54
  ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
55
+
56
+ # Copy application files
57
+ COPY --chown=user:user requirements.txt /app/requirements.txt
58
+ RUN pip install --user -r /app/requirements.txt
59
+
60
+ COPY --chown=user:user . /app
61
 
62
  # Set environment for CPU
63
  ENV CUDA_VISIBLE_DEVICES=""
64
  ENV FORCE_CUDA="0"
65
  ENV TORCH_CUDA_ARCH_LIST=""
66
 
67
+ # Expose port
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  EXPOSE 7860
69
+
70
+ # Run the application
71
  CMD ["python", "gradio_test.py"]
requirements.txt CHANGED
@@ -1,67 +1,19 @@
1
  # Core dependencies (torch and detectron2 installed in Dockerfile)
2
- numpy>=1.23.0,<2.0.0
3
- Pillow>=8.3.2
4
- opencv-python
5
- scipy
6
- scikit-learn
7
- scikit-image
8
- shapely
9
- h5py
10
- timm==0.4.12
11
- einops
12
- tqdm
13
- gradio>=4.0.0
14
- huggingface_hub
15
- matplotlib
16
- pycocotools
17
-
18
  # Git dependencies
19
  git+https://github.com/cocodataset/panopticapi.git
20
  git+https://github.com/mcordts/cityscapesScripts.git
21
 
22
- # Additional utilities
23
  imutils
24
  cython
25
- setuptools==59.5.0
26
- submitit
27
- icecream
28
- wandb
29
- ftfy
30
- regex
31
- inflect
32
- diffdist
33
- gdown
34
- wget# Core dependencies (torch and detectron2 installed in Dockerfile)
35
- numpy>=1.23.0,<2.0.0
36
- Pillow>=8.3.2
37
- opencv-python
38
- scipy
39
- scikit-learn
40
- scikit-image
41
- shapely
42
  h5py
43
  timm==0.4.12
44
  einops
45
- tqdm
46
- gradio>=4.0.0
47
- huggingface_hub
48
- matplotlib
49
- pycocotools
50
-
51
- # Git dependencies
52
- git+https://github.com/cocodataset/panopticapi.git
53
- git+https://github.com/mcordts/cityscapesScripts.git
54
-
55
- # Additional utilities
56
- imutils
57
- cython
58
- setuptools==59.5.0
59
  submitit
60
- icecream
61
- wandb
62
- ftfy
63
  regex
 
64
  inflect
65
  diffdist
66
- gdown
67
- wget
 
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