|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | 3 | set -e |
| 4 | + |
4 | 5 | usage() { |
5 | | - echo "Usage: $0 [script.sh] [cpu|gpu] [single|double]" |
| 6 | + echo "Usage: $0 [script.sh] [cpu|gpu]" |
6 | 7 | } |
7 | 8 |
|
8 | 9 | if [ ! -z "$1" ]; then |
9 | | - script_path="$1" |
| 10 | + sbatch_script_contents=`cat $1` |
10 | 11 | else |
11 | 12 | usage |
12 | 13 | exit 1 |
13 | 14 | fi |
14 | 15 |
|
| 16 | +sbatch_cpu_opts="\ |
| 17 | +#SBATCH -p cpu-small # partition |
| 18 | +#SBATCH --ntasks-per-node=24 # Number of cores per node required |
| 19 | +#SBATCH --mem-per-cpu=2G # Memory per core\ |
| 20 | +" |
| 21 | + |
| 22 | +sbatch_gpu_opts="\ |
| 23 | +#SBATCH -CV100-16GB |
| 24 | +#SBATCH -G2\ |
| 25 | +" |
| 26 | + |
15 | 27 | if [ "$2" == "cpu" ]; then |
16 | | - sbatch_device_opts="#SBATCH -p cpu-small |
17 | | -#SBATCH --ntasks-per-node=24 |
18 | | -#SBATCH --mem-per-cpu=2G" |
| 28 | + sbatch_device_opts="$sbatch_cpu_opts" |
19 | 29 | elif [ "$2" == "gpu" ]; then |
20 | | - sbatch_device_opts="#SBATCH -C V100-16GB |
21 | | -#SBATCH -G2" |
| 30 | + sbatch_device_opts="$sbatch_gpu_opts" |
22 | 31 | else |
23 | 32 | usage |
24 | 33 | exit 1 |
25 | 34 | fi |
26 | 35 |
|
27 | | -if [ "$3" != "single" ] && [ "$3" != "double" ]; then |
28 | | - usage |
29 | | - exit 1 |
| 36 | +# Set default precision to 'double' if not provided |
| 37 | + |
| 38 | +if [ -z "$3" ]; then |
| 39 | + precision="double" |
| 40 | +else |
| 41 | + if [ "$3" != "single" ] && [ "$3" != "double" ]; then |
| 42 | + usage |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + precision="$3" |
30 | 46 | fi |
31 | 47 |
|
32 | | -job_device="$2" |
33 | | -job_precision="$3" |
34 | | -job_slug="$(basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g')-$job_device-$job_precision" |
| 48 | + |
| 49 | +job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2-$precision" |
35 | 50 |
|
36 | 51 | sbatch <<EOT |
37 | 52 | #!/bin/bash |
38 | 53 | #SBATCH -Jshb-$job_slug # Job name |
39 | | -#SBATCH --account=gts-sbryngelson3 # Charge account |
| 54 | +#SBATCH --account=gts-sbryngelson3 # charge account |
40 | 55 | #SBATCH -N1 # Number of nodes required |
41 | 56 | $sbatch_device_opts |
42 | | -#SBATCH -t 02:00:00 # Duration of the job |
| 57 | +#SBATCH -t 02:00:00 # Duration of the job (Ex: 15 mins) |
43 | 58 | #SBATCH -q embers # QOS Name |
44 | | -#SBATCH -o $job_slug-$job_precision.out # Include precision in the log file |
| 59 | +#SBATCH -o$job_slug.out # Combined output and error messages file |
45 | 60 | #SBATCH -W # Do not exit until the submitted job terminates. |
46 | 61 |
|
47 | 62 | set -e |
48 | 63 | set -x |
49 | 64 |
|
50 | 65 | cd "\$SLURM_SUBMIT_DIR" |
51 | | -echo "Running in \$(pwd):" |
| 66 | +echo "Running in $(pwd):" |
52 | 67 |
|
53 | | -# Load necessary modules |
54 | | -. ./mfc.sh load -c p -m \$job_device |
| 68 | +job_slug="$job_slug" |
| 69 | +job_device="$2" |
| 70 | +job_precision="$precision" |
55 | 71 |
|
56 | | -# Execute the script with arguments |
57 | | -bash $script_path "\$job_device" "\$job_precision" |
58 | | -EOT |
| 72 | +. ./mfc.sh load -c p -m $2 |
59 | 73 |
|
| 74 | +$sbatch_script_contents |
| 75 | +EOT |
0 commit comments