-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_gpu_job.sh
executable file
·77 lines (71 loc) · 1.51 KB
/
make_gpu_job.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
#!/bin/bash
#defaults
wtime='01:00:00' # runtime limit
mem='2048M' # memory per node
ngpu=1 # number of gpus
prog='' # program to run, include the path
args='' # args for the program
title='' # title for the job
needarg=true # true if the program needs args, false otherwise
while [ $# -gt 0 ]; do
val=$1
shift
case $val in
"-ng")
ngpu=$1
shift
;;
"-t")
wtime=$1
shift
;;
"-m")
mem=$1
shift
;;
"-tt")
title=$1
shift
;;
"-pr")
prog=$1
shift
;;
"-na")
needarg=false
;;
*)
args=$val
;;
esac
done
if [[ -z $prog ]]; then
echo Did not give a program to run
exit
elif [[ -z $args ]] && [ "$needarg" = true ]; then
echo Did not give arguments
exit
elif [[ -z $title ]]; then
echo Did not give a title
exit
fi
cat << EOF > $title'_sub.sh'
#!/bin/bash
#SBATCH --account=def-mariusz
#SBATCH --gres=gpu:$ngpu
#SBATCH --mem=$mem
#SBATCH --time=$wtime
#SBATCH --job-name=$title
#SBATCH --output=%x-%j.out
echo ----------------------------------------
echo ----------------------------------------
echo began running on \`date\`
echo ----------------------------------------
echo ----------------------------------------
$prog $args
echo ----------------------------------------
echo ----------------------------------------
echo stopped running on \`date\`
echo ----------------------------------------
echo ----------------------------------------
EOF