-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmit-job.bash
67 lines (58 loc) · 1.56 KB
/
submit-job.bash
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
# NOTE: If you intend to run experiments on your own computing cluster, you
# should edit this file to submit batch jobs to your system. See the comment
# near "dummy-submit-batch-job-command" below.
set -e
set -u
set -o pipefail
usage() {
echo "Usage: $0 <job-name> <output-dir> <device> <command>...
Queues batch jobs.
Arguments:
<job-name> Unique name to identify this job.
<output-dir> Directory where additional outputs will be written, such as
the stdout of the command being run.
<device> Whether the job should be run on GPU or CPU.
One of: gpu, cpu
<command>... The command to be run.
"
}
job_name=${1-}
output_dir=${2-}
device=${3-}
if ! shift 3; then
usage >&2
exit 1
fi
args=("$@")
print_only=${PRINT_ONLY-0}
test_locally=${TEST_RUN-0}
case $device in
gpu)
# Possibly add different flags
;;
cpu)
# Possibly add different flags
;;
*)
echo "unrecognized device: $device" >&2
exit 1
;;
esac
# NOTE To run this on your own computing cluster, replace this with a command
# that submits batch jobs to your system.
submit_job_args=( \
dummy-submit-batch-job-command \
--job-name "$job_name" \
--output "$output_dir"/"$job_name".txt \
experiments/job-script.bash "$device" "${args[@]}"
)
if [[ $print_only != 0 ]]; then
echo "${submit_job_args[@]}"
elif [[ $test_locally != 0 ]]; then
echo "running $job_name with output directory $output_dir"
bash experiments/job-script.bash cpu "${args[@]}"
exit 1
else
echo "submitting $job_name"
"${submit_job_args[@]}"
fi