#!/usr/bin/env bash # BEAM_RISE: ONE 8-GPU gpu-mid job whose 8 slots drain status/beam/waves//queue.txt (flock'd cursor). # Never 1-GPU, never gpu-high. usage: GO=1 bash submit_wave.sh (no GO=1 = dry run) set -uo pipefail ROOT=/proj/dmfexp/zwhong/rsm_rise W=$1; WD=$ROOT/status/beam/waves/$W; Q=$WD/queue.txt [ -f "$Q" ] || { echo "no queue $Q"; exit 2; } P=${SL_PART:-gpu-mid}; case "$P" in *high*) echo "refusing $P"; exit 2;; esac case "${SL_QOS:-}" in *high*) echo "refusing QOS"; exit 2;; esac G=8 name=rr_pack8_beam_${W} sb=$WD/${name}.slurm.sh cat > $sb </dev/null || echo 0); echo \$((n+1)) > \$c; sed -n "\$((n+1))p" \$1' _ \$Q \${SLURM_JOB_ID:-0}; } slot() { s=\$1; while true; do c=\$(pop); [ -n "\$c" ] || break; echo "[slot\$s] \$(date -u +%T) start \$c"; CUDA_VISIBLE_DEVICES=\$s bash "\$c"; echo "[slot\$s] \$(date -u +%T) rc=\$? \$c"; done; } for s in 0 1 2 3 4 5 6 7; do slot \$s > $ROOT/logs/slurm/${name}.slot\$s.\${SLURM_JOB_ID:-0}.out 2>&1 & done wait; echo "[beam-pack] done \$(date -u)" EOS chmod +x $sb if [ "${GO:-0}" = 1 ]; then sbatch $sb; else echo "[dry] sbatch $sb"; cat $Q; fi