Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dockerfile to ensure proper build #381

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime
ARG DEBIAN_FRONTEND=noninteractive
FROM nvidia/cuda:11.3.1-devel-ubuntu20.04

ENV CUDA_HOME=/usr/local/cuda \
TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6+PTX" \
SETUPTOOLS_USE_DISTUTILS=stdlib
ENV CUDA_HOME=/usr/local/cuda-11.3/

RUN conda update conda -y
# Avoid interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive

# Install libraries in the brand new image.
RUN apt-get -y update && apt-get install -y --no-install-recommends \
wget \
build-essential \
git \
python3-opencv \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# System dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
wget \
python3.8 \
python3-pip \
python3-venv \
python3-opencv \
&& rm -rf /var/lib/apt/lists/*

# Set the working directory for all the subsequent Dockerfile instructions.
WORKDIR /opt/program
WORKDIR /app

# Clone GroundingDINO repo
RUN git clone https://github.com/IDEA-Research/GroundingDINO.git

RUN mkdir weights ; cd weights ; wget -q https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth ; cd ..
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113 && \
pip install networkx==2.6.3

RUN conda install -c "nvidia/label/cuda-12.1.1" cuda -y
ENV CUDA_HOME=$CONDA_PREFIX
# Install GroundingDINO requirements
RUN cd GroundingDINO && \
pip install -r requirements.txt && \
pip install -e .

ENV PATH=/usr/local/cuda/bin:$PATH
# Download pre-trained weights
RUN mkdir -p /app/weights && \
wget -P /app/weights https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth

RUN cd GroundingDINO/ && python -m pip install .
# Environment variables
ENV PYTHONPATH=/app/GroundingDINO
ENV CUDA_VISIBLE_DEVICES=0

COPY docker_test.py docker_test.py

CMD [ "python", "docker_test.py" ]
# Use JSON array format for CMD
CMD ["bash", "-c", "cd GroundingDINO && python3 demo/gradio_app.py"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ cv2.imwrite("annotated_image.jpg", annotated_frame)

We also provide a demo code to integrate Grounding DINO with Gradio Web UI. See the file `demo/gradio_app.py` for more details.

**Running Web UI with Docker**

To run the web UI using Docker, first build and run the container:

```bash
docker build -t grounding_dino .
docker run --gpus all --network host -it grounding_dino
```

**Notebooks**

- We release [demos](demo/image_editing_with_groundingdino_gligen.ipynb) to combine [Grounding DINO](https://arxiv.org/abs/2303.05499) with [GLIGEN](https://github.com/gligen/GLIGEN) for more controllable image editings.
Expand Down