forked from IDEA-Research/Grounded-Segment-Anything
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (40 loc) · 1.43 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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 := "3.5;5.0;6.0;6.1;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
build-image:
@echo $(BUILD_MESSAGE)
docker build --build-arg USE_CUDA=$(USE_CUDA) \
--build-arg TORCH_ARCH=$(TORCH_CUDA_ARCH_LIST) \
-t gsa:v0 .
run:
ifeq (,$(wildcard ./sam_vit_h_4b8939.pth))
wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
endif
ifeq (,$(wildcard ./groundingdino_swint_ogc.pth))
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
endif
docker run --gpus all -it --rm --net=host --privileged \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "${PWD}":/home/appuser/Grounded-Segment-Anything \
-e DISPLAY=$DISPLAY \
--name=gsa \
--ipc=host -it gsa:v0