-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·66 lines (58 loc) · 1.19 KB
/
run.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
#!/bin/bash
dir=$PWD
cpu="0-5"
gpu=""
# docker
img=tf2-cv
remove="true"
run="d"
name="hpv_status"
usage() { echo "usage: $0 [-n NAME] [-i DOCKER IMAGE] [-g GPU] [-c CPU CORES] [-r <it|d>] [-d REMOVE IMAGE]" 1>&2; exit 1; }
while [[ $# -gt 0 ]];
do
var="$1"
if [ ${var::1} == "-" ] || [ ${var::2} == "--" ]
then
opt=${var//-}
shift;
arg="$1"
case "$opt" in
"r"|"run")
run="$arg"
;;
"rm")
remove="$arg"
;;
"g"|"gpu")
gpu="$arg"
;;
"c"|"cpu")
cpu="$arg"
;;
"n"|"name")
name="$arg"
;;
*)
usage
esac
else
script=$var
shift;
fi
done
echo "running with flags: -$run --rm=$remove"
if [[ ! -z "${gpu// }" ]]; then
echo "on CPUs $cpu and GPU $gpu"
else
echo "on CPUs $cpu"
fi
read -p "Press enter to continue"
sudo docker run\
-$run\
--rm=$remove\
--cpuset-cpus=$cpu\
--gpus device=$gpu\
--name $name\
-v $dir:"/jobs"\
-w "/jobs"\
$img python $script