Repository navigation
Expand file tree
/
Copy pathtrain_hops.sh
More file actions
executable file
·36 lines (33 loc) · 1.67 KB
/
Copy pathtrain_hops.sh
File metadata and controls
executable file
·36 lines (33 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Train HOPS (baselines/hops.py) and keep going after you log out.
#
# bash train_hops.sh # hops_voc.yaml, 20k steps, detached
# CFG=configs/zero_shot/hops_ade.yaml bash train_hops.sh
# OUT=output/hops_smoke FG=1 bash train_hops.sh SOLVER.MAX_ITER 20 TEST.EVAL_PERIOD 0 # smoke test
#
# OUT defaults to output/<config name>. Trailing args are detectron2 KEY VALUE overrides.
# Re-running resumes from $OUT/last_checkpoint. Refuses to start while another process holds the
# GPU (shared server); FORCE=1 overrides that. Detached by default (nohup), log in $OUT/train.log;
# FG=1 runs in the foreground. Needs pretrain_weights/model_final_base.pth (CAT-Seg base).
set -euo pipefail
cd "$(dirname "$0")"
source ./pixi_setup.sh
CFG=${CFG:-configs/zero_shot/hops_voc.yaml}
OUT=${OUT:-output/$(basename "$CFG" .yaml)}
NUM_GPUS=${NUM_GPUS:-1}
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
[ -s pretrain_weights/model_final_base.pth ] || { echo "missing pretrain_weights/model_final_base.pth (see README, HOPS)"; exit 1; }
busy=$(nvidia-smi --query-compute-apps=pid,used_memory --format=csv,noheader)
if [ -n "$busy" ] && [ "${FORCE:-0}" != 1 ]; then
echo "GPU is in use by other processes; not starting (FORCE=1 to override):"; echo "$busy"; exit 1
fi
mkdir -p "$OUT"
cmd=(pixi run --frozen python train_net.py --num-gpus "$NUM_GPUS" --config-file "$CFG" --resume
OUTPUT_DIR "$OUT" PROGRESS_BAR False "$@")
if [ "${FG:-0}" = 1 ]; then
"${cmd[@]}"
else
nohup "${cmd[@]}" >> "$OUT/train.log" 2>&1 < /dev/null &
echo "started (PID $!), log: $OUT/train.log"
echo "follow: tail -f $OUT/train.log stop: kill $!"
fi