Mercurial > hg > cc > cirrus_home
annotate bin/runme.sh @ 202:491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Mon, 20 Apr 2026 18:22:38 +0100 |
| parents | 93dc3b9f70a6 |
| children | 2aa9db279d56 |
| rev | line source |
|---|---|
|
167
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
1 #!/usr/bin/bash |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
2 # Invoke this as e.g. sbatch --ntasks=10 -c 20 runme.sh [-m first last] [args for work/bin/_runme.sh] |
|
167
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
3 # It will run on the login node |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
4 # -m i j will launch _runme.sh multiple times with a -a in {first..last} |
|
167
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
5 |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
6 #SBATCH --time=01:00:00 |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
7 #SBATCH --partition=standard |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
8 #SBATCH --qos=standard |
|
196
436c976ed27f
try to get -m working properly
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
181
diff
changeset
|
9 #SBATCH --account=ec276-hst |
|
167
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
10 #SBATCH --job-name runme |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
11 |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
12 export W=/work/dc007/dc007 |
|
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
13 |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
14 if [ "$1" = "-m" ] |
|
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
15 then |
|
202
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
16 # Can't get this to work: timed out after an hour, and didn't run all 5 jobs |
|
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
17 # See slurm_s20-29x5_array.out and comments about that in notes.txt |
|
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
18 #echo "-m not supported" 1>&2 |
|
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
19 #exit 1 |
|
201
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
20 a=$SLURM_ARRAY_TASK_ID |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
21 echo "Array id $a $SLURM_ARRAY_TASK_COUNT" > mtest$a.out |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
22 ss=$2-$3 |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
23 shift; shift; shift; |
|
201
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
24 echo $(date) Launching $SLURM_JOB_NUM_NODES nodes in $(pwd) for runme -a $ss "$@" from $(hostname) to do $SLURM_NTASKS tasks, $SLURM_CPUS_PER_TASK cpus each >> mtest$a.out |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
25 echo $(date) Launching $a >> mtest$a.out |
|
202
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
26 srun -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh -a $a "$@" >> mtest$a.out |
|
201
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
27 echo $(date) Finished $a $? >> mtest$a.out |
|
202
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
28 exit 0 |
|
201
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
29 if [ "$exclude" ] |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
30 then |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
31 exclude+=",$SLURMD_NODENAME" |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
32 else |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
33 export exclude="--exclude=$SLURMD_NODENAME" |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
34 fi |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
35 echo $exclude >> mtest$a.out |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
36 else |
|
202
491b6d11dd14
works now with somewhat redundant --array=a-b and runme.sh -m a b
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
201
diff
changeset
|
37 echo $(date) Launching $SLURM_JOB_NUM_NODES nodes in $(pwd) for runme "$@" from $(hostname) to do $SLURM_NTASKS tasks, $SLURM_CPUS_PER_TASK cpus each |
|
167
3213a8bb2ed1
new style batch jobs, see cirrus_work repo for _xxx.sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff
changeset
|
38 |
|
181
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
39 srun --unbuffered -c $SLURM_CPUS_PER_TASK $W/shared/bin/sing $W/hst/bin/_runme.sh "$@" |
|
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
40 echo $(date) Finished |
|
55169996c3bf
add support for multiple calls to srun with a counter
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
178
diff
changeset
|
41 fi |
|
201
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
42 |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
43 |
|
93dc3b9f70a6
maybe got -m working using --array
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
199
diff
changeset
|
44 |
