Skip to content

Commit 06cdb68

Browse files
author
Archith Iyer
committed
more fixes
1 parent 23053e8 commit 06cdb68

File tree

1 file changed

+38
-22
lines changed

1 file changed

+38
-22
lines changed
Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,75 @@
11
#!/bin/bash
22

33
set -e
4+
45
usage() {
5-
echo "Usage: $0 [script.sh] [cpu|gpu] [single|double]"
6+
echo "Usage: $0 [script.sh] [cpu|gpu]"
67
}
78

89
if [ ! -z "$1" ]; then
9-
script_path="$1"
10+
sbatch_script_contents=`cat $1`
1011
else
1112
usage
1213
exit 1
1314
fi
1415

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+
1527
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"
1929
elif [ "$2" == "gpu" ]; then
20-
sbatch_device_opts="#SBATCH -C V100-16GB
21-
#SBATCH -G2"
30+
sbatch_device_opts="$sbatch_gpu_opts"
2231
else
2332
usage
2433
exit 1
2534
fi
2635

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"
3046
fi
3147

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"
3550

3651
sbatch <<EOT
3752
#!/bin/bash
3853
#SBATCH -Jshb-$job_slug # Job name
39-
#SBATCH --account=gts-sbryngelson3 # Charge account
54+
#SBATCH --account=gts-sbryngelson3 # charge account
4055
#SBATCH -N1 # Number of nodes required
4156
$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)
4358
#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
4560
#SBATCH -W # Do not exit until the submitted job terminates.
4661
4762
set -e
4863
set -x
4964
5065
cd "\$SLURM_SUBMIT_DIR"
51-
echo "Running in \$(pwd):"
66+
echo "Running in $(pwd):"
5267
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"
5571
56-
# Execute the script with arguments
57-
bash $script_path "\$job_device" "\$job_precision"
58-
EOT
72+
. ./mfc.sh load -c p -m $2
5973
74+
$sbatch_script_contents
75+
EOT

0 commit comments

Comments
 (0)