added Rocky Linux support and new Dockerfile for cpu
Browse files- Dockerfile +17 -75
- deform_setup_cpu.sh +11 -0
- requirements.txt +54 -13
Dockerfile
CHANGED
@@ -1,85 +1,31 @@
|
|
1 |
-
|
2 |
-
FROM python:3.8-slim as builder
|
3 |
|
|
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
git \
|
6 |
build-essential \
|
7 |
-
|
8 |
-
|
9 |
-
|
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 |
-
|
52 |
-
|
53 |
-
|
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 |
-
#
|
57 |
-
RUN
|
58 |
-
|
59 |
-
|
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,15 +34,11 @@ ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
|
88 |
# Copy application
|
89 |
COPY --chown=user:user . /app
|
90 |
|
91 |
-
#
|
92 |
-
COPY --chown=user:user requirements.txt /app/requirements.txt
|
93 |
-
RUN pip install --user --no-deps -r /app/requirements.txt || true
|
94 |
-
|
95 |
-
# Environment variables
|
96 |
ENV CUDA_VISIBLE_DEVICES=""
|
97 |
ENV FORCE_CUDA="0"
|
98 |
-
ENV
|
99 |
-
ENV
|
100 |
|
101 |
EXPOSE 7860
|
102 |
-
CMD ["python", "
|
|
|
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 |
+
wget \
|
8 |
+
curl \
|
9 |
+
ffmpeg \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
libsm6 \
|
11 |
libxext6 \
|
|
|
|
|
12 |
libgl1-mesa-glx \
|
|
|
13 |
&& rm -rf /var/lib/apt/lists/*
|
14 |
|
15 |
+
# Create user (required by HF Spaces)
|
16 |
RUN useradd -m -u 1000 user
|
17 |
|
18 |
WORKDIR /app
|
19 |
|
20 |
# Install Python packages
|
21 |
+
COPY requirements.txt .
|
22 |
+
RUN pip install --upgrade pip==22.3.1 && \
|
23 |
+
pip install --no-cache-dir -r requirements.txt
|
|
|
24 |
|
25 |
+
# Verify installations
|
26 |
+
RUN python -c "import torch; print(f'PyTorch: {torch.__version__}, CPU: {not torch.cuda.is_available()}')"
|
27 |
+
RUN python -c "import natten; print(f'NATTEN: {natten.__version__}')"
|
28 |
+
RUN python -c "import detectron2; print(f'Detectron2: {detectron2.__version__}')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Switch to user
|
31 |
USER user
|
|
|
34 |
# Copy application
|
35 |
COPY --chown=user:user . /app
|
36 |
|
37 |
+
# CPU optimizations
|
|
|
|
|
|
|
|
|
38 |
ENV CUDA_VISIBLE_DEVICES=""
|
39 |
ENV FORCE_CUDA="0"
|
40 |
+
ENV OMP_NUM_THREADS=4
|
41 |
+
ENV MKL_NUM_THREADS=4
|
42 |
|
43 |
EXPOSE 7860
|
44 |
+
CMD ["python", "gradio_app.py"]
|
deform_setup_cpu.sh
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
echo '----------------------------------------------------------------'
|
4 |
+
echo 'CPU Setup - Skipping CUDA operations compilation'
|
5 |
+
echo '----------------------------------------------------------------'
|
6 |
+
pip3 freeze | grep torch
|
7 |
+
pip3 freeze | grep detectron2
|
8 |
+
pip3 freeze | grep natten
|
9 |
+
echo '----------------------------------------------------------------'
|
10 |
+
echo 'CPU setup complete'
|
11 |
+
echo '----------------------------------------------------------------'
|
requirements.txt
CHANGED
@@ -1,24 +1,65 @@
|
|
1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
git+https://github.com/cocodataset/panopticapi.git@7bb4655
|
3 |
git+https://github.com/mcordts/cityscapesScripts.git@4f57ab6
|
4 |
|
5 |
-
#
|
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 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
ftfy==6.1.1
|
|
|
17 |
inflect==6.0.4
|
18 |
|
19 |
-
#
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# PyTorch CPU versions
|
2 |
+
--extra-index-url https://download.pytorch.org/whl/cpu
|
3 |
+
torch==1.9.0+cpu
|
4 |
+
torchvision==0.10.0+cpu
|
5 |
+
torchaudio==0.9.0
|
6 |
+
|
7 |
+
# Core dependencies
|
8 |
+
numpy==1.21.6
|
9 |
+
Pillow==8.3.2
|
10 |
+
|
11 |
+
# Detectron2 CPU version
|
12 |
+
-f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html
|
13 |
+
detectron2==0.6
|
14 |
+
|
15 |
+
# OpenCV
|
16 |
+
opencv-python==4.5.5.64
|
17 |
+
|
18 |
+
# Git dependencies
|
19 |
git+https://github.com/cocodataset/panopticapi.git@7bb4655
|
20 |
git+https://github.com/mcordts/cityscapesScripts.git@4f57ab6
|
21 |
|
22 |
+
# Image utilities
|
23 |
imutils==0.5.4
|
24 |
+
|
25 |
+
# NATTEN CPU version for torch 1.9
|
26 |
+
-f https://shi-labs.com/natten/wheels/cpu/torch1.9/index.html
|
27 |
+
natten==0.14.6
|
28 |
+
|
29 |
+
# Build tools
|
30 |
cython==0.29.35
|
31 |
+
setuptools==59.5.0
|
32 |
+
|
33 |
+
# Scientific computing
|
34 |
+
scipy==1.7.3
|
35 |
+
shapely==1.8.5
|
36 |
h5py==3.7.0
|
37 |
+
scikit-image==0.19.3
|
38 |
+
|
39 |
+
# Deep learning utilities
|
40 |
timm==0.4.12
|
41 |
einops==0.6.1
|
42 |
+
|
43 |
+
# Development tools
|
44 |
+
icecream==2.1.3
|
45 |
+
wandb==0.13.5
|
46 |
+
tqdm==4.64.1
|
47 |
+
|
48 |
+
# NLP utilities
|
49 |
ftfy==6.1.1
|
50 |
+
regex==2022.10.31
|
51 |
inflect==6.0.4
|
52 |
|
53 |
+
# File utilities
|
54 |
+
gdown==4.5.4
|
55 |
+
wget==3.2
|
56 |
+
huggingface_hub==0.11.1
|
57 |
+
|
58 |
+
# Training framework
|
59 |
+
pytorch_lightning==1.8.6
|
60 |
+
|
61 |
+
# Web interface
|
62 |
+
gradio==3.16.2
|
63 |
+
|
64 |
+
# Job submission
|
65 |
+
submitit==1.4.5
|