-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjob-script.bash
50 lines (45 loc) · 867 Bytes
/
job-script.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
#!/bin/bash
set -e
set -u
set -o pipefail
usage() {
echo "Usage: <device> <command>...
<device> One of: cpu, gpu
"
}
device=${1-}
if ! shift 1; then
usage >&2
exit 1
fi
# Show some information about the job.
echo "Arguments:"
escaped_args=()
for arg in "$@"; do
escaped_args+=("$(printf %q "$arg")")
done
printf '%s\n' "${escaped_args[*]}"
echo "Timestamp: $(date)"
echo "Host: $(hostname)"
case $device in
cpu) ;;
gpu)
echo "GPUs:"
nvidia-smi --query-gpu=name --format=csv | tail -n +2
echo "CUDA_VISIBLE_DEVICES: $CUDA_VISIBLE_DEVICES"
echo 'Output of nvidia-smi:'
nvidia-smi
echo 'Users:'
users
echo 'Process tree:'
ps -e f
;;
*)
usage >&2
exit 1
;;
esac
echo '==== Start of job ===='
bash experiments/run-singularity.bash \
"$device" \
bash -c 'cd src && poetry run -- "$@"' -- "$@"