-
Notifications
You must be signed in to change notification settings - Fork 0
/
torch
executable file
·88 lines (81 loc) · 2.05 KB
/
torch
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
#!/usr/bin/env bash
POSITIONAL=()
set -e
function usage() {
#TODO : rewrite Usage
printf 'Usage: torch [-b/--bind dirname] [-s/--shell] [-p/--python filename] [-c commands] \n'
}
singularity="/usr/local/bin/singularity"
torch_img="/opt/singularity/torch-jskim.sif"
cmd="help"
bpath="run"
pyexec="python --version"
testexec="pytest"
cmexec="ls /mnt"
while [[ $# -gt 0 ]]
do
cmd="$1"
case $cmd in
-b|--bind)
bpath="$2"
shift
shift
;;
-c|--command)
cmd="cmd"
shift
cmexec="$*"
break
;;
-p|--python)
cmd="python"
pyexec="python $2"
shift
shift
break
;;
-s|--shell)
cmd="shell"
shift
break
;;
-t|--test)
cmd="test"
testexec="pytest --pyargs $2"
shift
break
;;
-h|--help)
cmd="help"
shift
break
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# create directory for mount
mkdir -p /data/appleparan/"${bpath}"
case $cmd in
cmd)
${singularity} exec --nv --bind "${HOME}"/input:/input,/data/appleparan/"${bpath}":/mnt/data --nv ${torch_img} "${cmexec}"
;;
python)
source activate
${singularity} exec --nv --bind "${HOME}"/input:/input,/data/appleparan/"${bpath}":/mnt/data --nv ${torch_img} ${pyexec}
;;
shell)
${singularity} shell --nv --bind "${HOME}"/input:/input,/data/appleparan/"${bpath}":/mnt/data --nv ${torch_img}
;;
test)
source activate
${singularity} exec --nv --bind "${HOME}"/input:/input,/data/appleparan/"${bpath}":/mnt/data --nv ${torch_img} ${testexec}
;;
help)
usage
exit 0
;;
esac