forked from open-mmlab/mmsegmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_docker_mmseg.sh
executable file
·100 lines (83 loc) · 2.74 KB
/
run_docker_mmseg.sh
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
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
CONTAINER_NAME="mmsegmentation"
IMAGE_TAG=mmsegmentation:latest
BUILD=true
INTERACTIVE=true
function print_usage {
printf "Usage: run_docker_mmseg.sh [OPTIONS] CMD [ARGS...]
Example usage:
- ./run_docker_mmseg -r /data/mmsegmentation/experiment_x python3 tools.train configs/amr_segmentation/vit_uper.py
- ./run_docker_mmseg -r /data/mmsegmentation/experiment_x bash
Options:
-d data directory with 'dataset' subfolder (default=/data/mmsegmentation/)
-r result directory where to store results to (default=/data/mmsegmentation/model)
-p pretrain directory with pretrained models (default=/data/ml_models/models/mmsegmentation/pretrained)
-b build Docker image before running (default=true)
-i run Docker in interactive mode (default=true)
-t set custom image tag (default=mmsegmentation:latest)
-h prints this help\n\n"
if [ ! -z "$1" ]; then
echo "$@"
exit 1
fi
exit 0
}
opts="d:p:r:b:i:t:h"
while getopts "$opts" flag; do
case "${flag}" in
d) DATA_DIR="$OPTARG" ;;
p) PRETRAIN_DIR="$OPTARG" ;;
r) RESULT_DIR="$OPTARG" ;;
b) BUILD="$OPTARG" ;;
i) INTERACTIVE="$OPTARG" ;;
t) IMAGE_TAG="$OPTARG" ;;
h) print_usage ;;
*) print_usage "Unrecognized argument '$flag'" ;;
esac
done
shift $((OPTIND-1))
[[ ! -z $1 ]] || 1=bash
REPO_DIR=/code/mmsegmentation
echo "IMAGE_TAG=$IMAGE_TAG"
# defaults and strip tailing slash
DATA_DIR="${DATA_DIR:-/data/mmsegmentation/}"
DATA_DIR="${DATA_DIR%%/}"
echo "DATA_DIR=$DATA_DIR"
RESULT_DIR="${RESULT_DIR:-/data/mmsegmentation/model/}"
RESULT_DIR="${RESULT_DIR%%/}"
echo "RESULT_DIR=$RESULT_DIR"
PRETRAIN_DIR="${PRETRAIN_DIR:-/data/ml_models/models/mmsegmentation/pretrained}"
PRETRAIN_DIR="${PRETRAIN_DIR%%/}"
echo "PRETRAIN_DIR=$PRETRAIN_DIR"
if [ "$BUILD" = true ]; then
docker build --progress=plain -t $IMAGE_TAG docker/
fi
docker rm -f "$CONTAINER_NAME"
# hack create artificial home for user, with ownership of current host user
mkdir -p "$DATA_DIR/.home"
mkdir -p "$RESULT_DIR"
mkdir -p "$PRETRAIN_DIR"
if [ "$INTERACTIVE" = true ]; then
RUN_MODE="-it"
else
RUN_MODE="-t"
fi
#python3 -m tools.train configs/amr_segmentation/vit_uper.py
#-d --restart=unless-stopped \
docker run \
$RUN_MODE \
--gpus all \
--shm-size=8g \
--name "$CONTAINER_NAME" \
--user "$(id -u):$(id -g)" \
-v "/etc/group:/etc/group:ro" \
-v "/etc/passwd:/etc/passwd:ro" \
-v "/etc/shadow:/etc/shadow:ro" \
-v "${DATA_DIR}:/data/" \
-v "$DATA_DIR/.home:$HOME:rw" \
-v "${PRETRAIN_DIR}:/mmsegmentation/pretrain/" \
-v "${RESULT_DIR}:/results/" \
-v "${REPO_DIR}:/mmsegmentation/" \
-w /mmsegmentation \
$IMAGE_TAG \
"$@"