Fix Dockerfile to ensure proper build

pull/381/head
Alex 2025-02-02 15:38:57 +04:00
parent 856dde20ae
commit d6d7b921aa
2 changed files with 41 additions and 24 deletions

View File

@ -1,35 +1,43 @@
FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime FROM nvidia/cuda:11.3.1-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
ENV CUDA_HOME=/usr/local/cuda \ ENV CUDA_HOME=/usr/local/cuda-11.3/
TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6+PTX" \
SETUPTOOLS_USE_DISTUTILS=stdlib
RUN conda update conda -y # Avoid interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive
# Install libraries in the brand new image. # System dependencies
RUN apt-get -y update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
wget \ build-essential \
build-essential \ git \
git \ wget \
python3-opencv \ python3.8 \
ca-certificates && \ python3-pip \
rm -rf /var/lib/apt/lists/* python3-venv \
python3-opencv \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory for all the subsequent Dockerfile instructions. WORKDIR /app
WORKDIR /opt/program
# Clone GroundingDINO repo
RUN git clone https://github.com/IDEA-Research/GroundingDINO.git 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 # Install GroundingDINO requirements
ENV CUDA_HOME=$CONDA_PREFIX 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 # Use JSON array format for CMD
CMD ["bash", "-c", "cd GroundingDINO && python3 demo/gradio_app.py"]
CMD [ "python", "docker_test.py" ]

View File

@ -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. 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** **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. - 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.