-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (69 loc) · 2.27 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Created by: George Corrêa de Araújo ([email protected])
# ==================================================================
# environment variables
# ------------------------------------------------------------------
DOCKERFILE_CONTEXT = $(PWD)
DOCKERFILE = $(PWD)/Dockerfile
DATA_DIR = $(HOME)/datasets/ai_papers
WORK_DIR = $(PWD)
RUN_STRING = bash start_here.sh
# ==================================================================
# Docker settings
# ------------------------------------------------------------------
CONTAINER_NAME = nlp-papers-$(USER)-$(shell echo $$STY | cut -d'.' -f2)
CONTAINER_FILE = nlp-papers-$(USER).tar
HOSTNAME = docker-$(shell hostname)
IMAGE_NAME = $(USER)/ai-papers-nlp
DATA_PATH = /work/data
WORK_PATH = /work
PDB_MOUNT_STRING = --mount type=bind,source=/home/$(USER)/.pdbhistory,target=/home/$(USER)/.pdbhistory
RUN_CONFIG_STRING = --name $(CONTAINER_NAME) --hostname $(HOSTNAME) --rm -it --dns 8.8.8.8 \
--userns=host --ipc=host --ulimit memlock=-1 -w $(WORK_PATH) $(IMAGE_NAME):latest
DATA_MOUNT_STRING = --mount type=bind,source=$(DATA_DIR),target=$(DATA_PATH)
WORK_MOUNT_STRING = --mount type=bind,source=$(WORK_DIR),target=$(WORK_PATH)
# ==================================================================
# Make commands
# ------------------------------------------------------------------
# Build image
build:
docker build \
--build-arg GROUPID=$(shell id -g) \
--build-arg GROUPNAME=$(shell id -gn) \
--build-arg USERID=$(shell id -u) \
--build-arg USERNAME=$(USER) \
-f $(DOCKERFILE) \
--pull --no-cache --force-rm \
-t $(IMAGE_NAME) \
$(DOCKERFILE_CONTEXT)
# Remove the image
clean:
docker rmi $(IMAGE_NAME)
# Load image from file
load:
docker load -i $(CONTAINER_FILE)
# Kill running container
kill:
docker kill $(CONTAINER_NAME)
# Run RUN_STRING inside container
run:
docker run \
$(WORK_MOUNT_STRING) \
$(DATA_MOUNT_STRING) \
$(PDB_MOUNT_STRING) \
$(RUN_CONFIG_STRING) \
$(RUN_STRING)
# Save image to file
save:
docker save -o $(CONTAINER_FILE) $(IMAGE_NAME)
# Start container by opening shell
start:
docker run \
$(WORK_MOUNT_STRING) \
$(DATA_MOUNT_STRING) \
$(PDB_MOUNT_STRING) \
$(RUN_CONFIG_STRING)
# Test image by printing some info
test:
nvidia-docker run \
$(RUN_CONFIG_STRING) \
python -V