fix:add makefile and dockerfile
This commit is contained in:
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-devel
|
||||
|
||||
# Arguments to build Docker Image using CUDA
|
||||
ARG USE_CUDA=0
|
||||
ARG TORCH_ARCH="7.0;7.5;8.0;8.6"
|
||||
|
||||
ENV AM_I_DOCKER True
|
||||
ENV BUILD_WITH_CUDA "${USE_CUDA}"
|
||||
ENV TORCH_CUDA_ARCH_LIST="${TORCH_ARCH}"
|
||||
ENV CUDA_HOME /usr/local/cuda-12.1/
|
||||
# Ensure CUDA is correctly set up
|
||||
ENV PATH /usr/local/cuda-12.1/bin:${PATH}
|
||||
ENV LD_LIBRARY_PATH /usr/local/cuda-12.1/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
# Install required packages and specific gcc/g++
|
||||
RUN apt-get update && apt-get install --no-install-recommends wget ffmpeg=7:* \
|
||||
libsm6=2:* libxext6=2:* git=1:* nano vim=2:* ninja-build gcc-10 g++-10 -y \
|
||||
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV CC=gcc-10
|
||||
ENV CXX=g++-10
|
||||
|
||||
RUN mkdir -p /home/appuser/Grounded-SAM-2
|
||||
COPY . /home/appuser/Grounded-SAM-2/
|
||||
|
||||
WORKDIR /home/appuser/Grounded-SAM-2
|
||||
|
||||
|
||||
# Install essential Python packages
|
||||
RUN python -m pip install --upgrade pip setuptools wheel numpy
|
||||
|
||||
# Install segment_anything package in editable mode
|
||||
RUN python -m pip install -e .
|
||||
|
47
Makefile
Normal file
47
Makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
# Get version of CUDA and enable it for compilation if CUDA > 11.0
|
||||
# This solves https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/53
|
||||
# and https://github.com/IDEA-Research/Grounded-Segment-Anything/issues/84
|
||||
# when running in Docker
|
||||
# Check if nvcc is installed
|
||||
NVCC := $(shell which nvcc)
|
||||
ifeq ($(NVCC),)
|
||||
# NVCC not found
|
||||
USE_CUDA := 0
|
||||
NVCC_VERSION := "not installed"
|
||||
else
|
||||
NVCC_VERSION := $(shell nvcc --version | grep -oP 'release \K[0-9.]+')
|
||||
USE_CUDA := $(shell echo "$(NVCC_VERSION) > 11" | bc -l)
|
||||
endif
|
||||
|
||||
# Add the list of supported ARCHs
|
||||
ifeq ($(USE_CUDA), 1)
|
||||
TORCH_CUDA_ARCH_LIST := "7.0;7.5;8.0;8.6+PTX"
|
||||
BUILD_MESSAGE := "I will try to build the image with CUDA support"
|
||||
else
|
||||
TORCH_CUDA_ARCH_LIST :=
|
||||
BUILD_MESSAGE := "CUDA $(NVCC_VERSION) is not supported"
|
||||
endif
|
||||
|
||||
|
||||
prepare-checkpoints:
|
||||
@echo "Preparing checkpoints..."
|
||||
cd checkpoints && \
|
||||
bash download_ckpts.sh && \
|
||||
mkdir -p gdino_checkpoints && \
|
||||
cd gdino_checkpoints && \
|
||||
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth && \
|
||||
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha2/groundingdino_swinb_cogcoor.pth
|
||||
|
||||
|
||||
build-image:
|
||||
@echo $(BUILD_MESSAGE)
|
||||
docker build --build-arg USE_CUDA=$(USE_CUDA) \
|
||||
--build-arg TORCH_ARCH=$(TORCH_CUDA_ARCH_LIST) \
|
||||
-t grounded_sam2:1.0 .
|
||||
run:
|
||||
docker run --gpus all -it --rm --net=host --privileged \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
-v "${PWD}":/home/appuser/Grounded-SAM-2 \
|
||||
-e DISPLAY=$DISPLAY \
|
||||
--name=gsa \
|
||||
--ipc=host -it grounded_sam2:1.0
|
24
gdino_checkpoints/download_ckpts.sh
Normal file
24
gdino_checkpoints/download_ckpts.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
# All rights reserved.
|
||||
|
||||
# This source code is licensed under the license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
|
||||
# Define the URLs for the checkpoints
|
||||
BASE_URL="https://github.com/IDEA-Research/GroundingDINO/releases/download/"
|
||||
swint_ogc_url="${BASE_URL}v0.1.0-alpha/groundingdino_swint_ogc.pth"
|
||||
swinb_cogcoor_url="${BASE_URL}v0.1.0-alpha2/groundingdino_swinb_cogcoor.pth"
|
||||
|
||||
|
||||
|
||||
# Download each of the four checkpoints using wget
|
||||
echo "Downloading groundingdino_swint_ogc.pth checkpoint..."
|
||||
wget $swint_ogc_url || { echo "Failed to download checkpoint from $swint_ogc_url"; exit 1; }
|
||||
|
||||
echo "Downloading groundingdino_swinb_cogcoor.pth checkpoint..."
|
||||
wget $swinb_cogcoor_url || { echo "Failed to download checkpoint from $swinb_cogcoor_url"; exit 1; }
|
||||
|
||||
echo "All checkpoints are downloaded successfully."
|
@@ -92,6 +92,10 @@ def get_extensions():
|
||||
"-D__CUDA_NO_HALF_OPERATORS__",
|
||||
"-D__CUDA_NO_HALF_CONVERSIONS__",
|
||||
"-D__CUDA_NO_HALF2_OPERATORS__",
|
||||
"-gencode=arch=compute_70,code=sm_70",
|
||||
"-gencode=arch=compute_75,code=sm_75",
|
||||
"-gencode=arch=compute_80,code=sm_80",
|
||||
"-gencode=arch=compute_86,code=sm_86",
|
||||
]
|
||||
else:
|
||||
print("Compiling without CUDA")
|
||||
@@ -208,7 +212,7 @@ if __name__ == "__main__":
|
||||
url="https://github.com/IDEA-Research/GroundingDINO",
|
||||
description="open-set object detector",
|
||||
license=license,
|
||||
install_requires=parse_requirements("requirements.txt"),
|
||||
# install_requires=parse_requirements("requirements.txt"),
|
||||
packages=find_packages(
|
||||
exclude=(
|
||||
"configs",
|
||||
|
17
setup.py
17
setup.py
@@ -25,11 +25,28 @@ with open("README.md", "r") as f:
|
||||
REQUIRED_PACKAGES = [
|
||||
"torch>=2.3.1",
|
||||
"torchvision>=0.18.1",
|
||||
"transformers",
|
||||
"numpy>=1.24.4",
|
||||
"tqdm>=4.66.1",
|
||||
"hydra-core>=1.3.2",
|
||||
"iopath>=0.1.10",
|
||||
"pillow>=9.4.0",
|
||||
"huggingface_hub",
|
||||
"diffusers[torch]==0.15.1",
|
||||
"onnxruntime==1.14.1",
|
||||
"onnx==1.13.1",
|
||||
"ipykernel==6.16.2",
|
||||
"scipy",
|
||||
"gradio",
|
||||
"openai",
|
||||
"matplotlib>=3.9.1",
|
||||
"opencv-python>=4.7.0",
|
||||
"dds_cloudapi_sdk",
|
||||
"addict",
|
||||
"yapf",
|
||||
"timm",
|
||||
"supervision>=0.22.0",
|
||||
"pycocotools",
|
||||
]
|
||||
|
||||
EXTRA_PACKAGES = {
|
||||
|
Reference in New Issue
Block a user