Spaces:
Sleeping
Sleeping
zeeshan
commited on
Commit
·
b25a606
1
Parent(s):
dfd57a5
Use HF-optimized Dockerfile for deployment
Browse files- Dockerfile +13 -40
- Dockerfile.cuda +58 -0
Dockerfile
CHANGED
|
@@ -1,58 +1,31 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
|
| 7 |
# Install system dependencies
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
| 10 |
-
python3.8 \
|
| 11 |
-
python3-distutils \
|
| 12 |
-
python3-pip \
|
| 13 |
git \
|
| 14 |
build-essential \
|
| 15 |
libsm6 \
|
| 16 |
libxext6 \
|
| 17 |
libgl1 \
|
| 18 |
-
|
| 19 |
-
libssl-dev \
|
| 20 |
-
wget \
|
| 21 |
-
curl && \
|
| 22 |
-
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 && \
|
| 23 |
-
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
|
| 24 |
-
pip install --upgrade pip setuptools wheel && \
|
| 25 |
apt-get clean && \
|
| 26 |
rm -rf /var/lib/apt/lists/*
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
# Install PyTorch 1.11.0 with CUDA 11.3
|
| 32 |
-
RUN pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 \
|
| 33 |
-
-f https://download.pytorch.org/whl/cu113/torch_stable.html
|
| 34 |
|
| 35 |
-
# Install
|
| 36 |
-
RUN pip install -
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# Install timm and mmdet
|
| 40 |
-
RUN pip install timm==0.6.11 mmdet==2.28.1
|
| 41 |
-
|
| 42 |
-
# Install utility libraries
|
| 43 |
-
RUN pip install Pillow==9.5.0 opencv-python termcolor yacs pyyaml scipy
|
| 44 |
-
|
| 45 |
-
# Install DCNv3 wheel (compatible with Python 3.8, Torch 1.11, CUDA 11.3)
|
| 46 |
-
RUN pip install https://github.com/OpenGVLab/InternImage/releases/download/whl_files/DCNv3-1.0+cu113torch1.11.0-cp38-cp38-linux_x86_64.whl
|
| 47 |
|
| 48 |
# Copy application code
|
| 49 |
COPY . /app/
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# Expose ports for frontend (8080) and backend (8000)
|
| 55 |
-
EXPOSE 8000 8080
|
| 56 |
-
|
| 57 |
-
# Default command
|
| 58 |
-
CMD ["/bin/bash"]
|
|
|
|
| 1 |
+
# HuggingFace Spaces compatible Dockerfile
|
| 2 |
+
FROM python:3.8-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
|
| 7 |
# Install system dependencies
|
| 8 |
RUN apt-get update && \
|
| 9 |
apt-get install -y --no-install-recommends \
|
|
|
|
|
|
|
|
|
|
| 10 |
git \
|
| 11 |
build-essential \
|
| 12 |
libsm6 \
|
| 13 |
libxext6 \
|
| 14 |
libgl1 \
|
| 15 |
+
libglib2.0-0 \
|
| 16 |
+
libssl-dev && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
apt-get clean && \
|
| 18 |
rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
# Copy requirements
|
| 21 |
+
COPY requirements.txt /app/
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
# Install Python dependencies
|
| 24 |
+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Copy application code
|
| 28 |
COPY . /app/
|
| 29 |
|
| 30 |
+
# Run backend on port 7860 (HuggingFace standard)
|
| 31 |
+
CMD ["uvicorn", "deployment.backend.backend_amar:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile.cuda
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Base Image: NVIDIA CUDA 11.3 with cuDNN8 on Ubuntu 20.04
|
| 2 |
+
FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04
|
| 3 |
+
|
| 4 |
+
# Set non-interactive mode
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && \
|
| 9 |
+
apt-get install -y --no-install-recommends \
|
| 10 |
+
python3.8 \
|
| 11 |
+
python3-distutils \
|
| 12 |
+
python3-pip \
|
| 13 |
+
git \
|
| 14 |
+
build-essential \
|
| 15 |
+
libsm6 \
|
| 16 |
+
libxext6 \
|
| 17 |
+
libgl1 \
|
| 18 |
+
gfortran \
|
| 19 |
+
libssl-dev \
|
| 20 |
+
wget \
|
| 21 |
+
curl && \
|
| 22 |
+
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 && \
|
| 23 |
+
update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 && \
|
| 24 |
+
pip install --upgrade pip setuptools wheel && \
|
| 25 |
+
apt-get clean && \
|
| 26 |
+
rm -rf /var/lib/apt/lists/*
|
| 27 |
+
|
| 28 |
+
# Set working directory
|
| 29 |
+
WORKDIR /app
|
| 30 |
+
|
| 31 |
+
# Install PyTorch 1.11.0 with CUDA 11.3
|
| 32 |
+
RUN pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 \
|
| 33 |
+
-f https://download.pytorch.org/whl/cu113/torch_stable.html
|
| 34 |
+
|
| 35 |
+
# Install OpenMMLab dependencies
|
| 36 |
+
RUN pip install -U openmim && \
|
| 37 |
+
mim install mmcv-full==1.5.0
|
| 38 |
+
|
| 39 |
+
# Install timm and mmdet
|
| 40 |
+
RUN pip install timm==0.6.11 mmdet==2.28.1
|
| 41 |
+
|
| 42 |
+
# Install utility libraries
|
| 43 |
+
RUN pip install Pillow==9.5.0 opencv-python termcolor yacs pyyaml scipy
|
| 44 |
+
|
| 45 |
+
# Install DCNv3 wheel (compatible with Python 3.8, Torch 1.11, CUDA 11.3)
|
| 46 |
+
RUN pip install https://github.com/OpenGVLab/InternImage/releases/download/whl_files/DCNv3-1.0+cu113torch1.11.0-cp38-cp38-linux_x86_64.whl
|
| 47 |
+
|
| 48 |
+
# Copy application code
|
| 49 |
+
COPY . /app/
|
| 50 |
+
|
| 51 |
+
# Install any Python dependencies from requirements.txt (if it exists)
|
| 52 |
+
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
| 53 |
+
|
| 54 |
+
# Expose ports for frontend (8080) and backend (8000)
|
| 55 |
+
EXPOSE 8000 8080
|
| 56 |
+
|
| 57 |
+
# Default command
|
| 58 |
+
CMD ["/bin/bash"]
|