#!/usr/bin/env bash # protocol_bench (configs/protocol_bench.yaml) driver on the Linux GPU server: every stage is wrapped by # ml_porosity.runlog (logs/runs/_bench_/, logs/index.csv) and is restartable (completed jobs are skipped # by fingerprint and checksum). Long runs: detach with `setsid nohup scripts/run_bench.sh ... > logs/bench_.out 2>&1 &`. # scripts/run_bench.sh lock # first lock (after the review of the draft) # STUDIES="S1" DEVICE=cuda:0 WORKERS=4 scripts/run_bench.sh posterior train # STUDIES="S3 S4 S8" DEVICE=cuda:1 scripts/run_bench.sh train # scripts/run_bench.sh summarize | status | repro # DEV=1 RIDS="902 903" STUDIES="S2" PRESETS="rp_L1 wv_L1" scripts/run_bench.sh posterior train # dev (never a result) # Env: DEVICE (default cuda:0), WORKERS (4), THREADS per worker (2), MEM_GB per SMC worker (6), STUDIES, REGIMES, # PRESETS, RIDS, DEV (1 → --dev), CONTROLS (1 → S2 controls), EXTRA (extra arguments). set -euo pipefail cd "$(dirname "$0")/.." PY="${PY:-.venv/bin/python}" DEVICE="${DEVICE:-cuda:0}" WORKERS="${WORKERS:-4}" THREADS="${THREADS:-2}" MEM_GB="${MEM_GB:-6}" STUDIES="${STUDIES:-S1 S2 S3 S4 S8}" export OMP_NUM_THREADS=$THREADS MKL_NUM_THREADS=$THREADS OPENBLAS_NUM_THREADS=$THREADS NUMEXPR_NUM_THREADS=$THREADS \ NUMBA_NUM_THREADS=$THREADS PYTHONHASHSEED=0 PYTHONUTF8=1 CUBLAS_WORKSPACE_CONFIG=:4096:8 args=(--device "$DEVICE" --workers "$WORKERS" --threads "$THREADS" --gpu-mem-gb "$MEM_GB") # shellcheck disable=SC2206 args+=(--studies $STUDIES) [[ -n "${REGIMES:-}" ]] && args+=(--regimes $REGIMES) [[ -n "${PRESETS:-}" ]] && args+=(--presets $PRESETS) [[ -n "${RIDS:-}" ]] && args+=(--rids $RIDS) [[ "${DEV:-0}" == "1" ]] && args+=(--dev) [[ "${CONTROLS:-0}" == "1" ]] && args+=(--controls) [[ -n "${EXTRA:-}" ]] && args+=($EXTRA) tag="$(echo "$STUDIES" | tr ' ' '+')" [[ "${DEV:-0}" == "1" ]] && tag="dev_$tag" for stage in "${@:-status}"; do case "$stage" in status|lock|summarize|repro) "$PY" -m ml_porosity.runlog -n "bench_${stage}" -- "$PY" scripts/34_run_bench.py "$stage" "${args[@]}" ;; posterior|train|dev-budgets) "$PY" -m ml_porosity.runlog -n "bench_${stage}_${tag}_${DEVICE//:/}" -- "$PY" scripts/34_run_bench.py "$stage" "${args[@]}" ;; *) echo "unknown stage: $stage" >&2; exit 2 ;; esac done