-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
59 lines (45 loc) · 1.52 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#################
# CPU, TPU or GPU. If you enter an incorrect option, it will default to CPU-only
ACCELERATOR = TPU
# variables
WORK_DIR = $(PWD)
USER_ID = $$(id -u)
GROUP_ID = $$(id -g)
DOCKER_BUILD_FLAGS = --build-arg USER_ID=$(USER_ID) \
--build-arg GROUP_ID=$(GROUP_ID) \
ifeq ($(ACCELERATOR), GPU)
DOCKER_BUILD_FLAGS += --build-arg BASE_IMAGE="nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04"
endif
ifeq ($(ACCELERATOR), TPU)
DOCKER_BUILD_FLAGS += --build-arg BASE_IMAGE="ubuntu:20.04"
endif
ifeq ($(ACCELERATOR), CPU)
DOCKER_BUILD_FLAGS += --build-arg BASE_IMAGE="ubuntu:20.04"
endif
DOCKER_RUN_FLAGS_CPU = --rm \
--shm-size=1024m \
-v $(WORK_DIR):/app
DOCKER_RUN_FLAGS_GPU = ${DOCKER_RUN_FLAGS_CPU} --gpus all
DOCKER_RUN_FLAGS_TPU = --rm --user root --privileged \
-v $(WORK_DIR):/app
# Select appropriate run flags based on accelerator
ifeq ($(ACCELERATOR), CPU)
DOCKER_RUN_FLAGS = $(DOCKER_RUN_FLAGS_CPU)
else ifeq ($(ACCELERATOR), GPU)
DOCKER_RUN_FLAGS = $(DOCKER_RUN_FLAGS_GPU)
else ifeq ($(ACCELERATOR), TPU)
DOCKER_RUN_FLAGS = $(DOCKER_RUN_FLAGS_TPU)
endif
# image + container name
DOCKER_IMAGE_NAME = protbfn
DOCKER_CONTAINER_NAME = protbfn_container
.PHONY: build
build:
sudo docker build -t $(DOCKER_IMAGE_NAME) -f Dockerfile . \
$(DOCKER_BUILD_FLAGS) --build-arg ACCELERATOR=$(ACCELERATOR) \
.PHONY: sample
sample:
sudo docker run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_NAME) python sample.py $(RUN_ARGS)
.PHONY: inpaint
inpaint:
sudo docker run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_NAME) python inpaint.py $(RUN_ARGS)