AjayRangoji commited on
Commit
f509251
·
verified ·
1 Parent(s): df1a3ac

Upload scripts

Browse files
Files changed (2) hide show
  1. scripts/launch.sh +35 -0
  2. scripts/run_baselines.sh +24 -0
scripts/launch.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Launch training on a remote node, pinning CUDA_VISIBLE_DEVICES.
3
+ # Usage: scripts/launch.sh <node-ip> <config> <seed> [gpu-index-or-auto]
4
+ # Default "auto" claims the first GPU with no compute processes.
5
+ set -euo pipefail
6
+ NODE=$1; CONFIG=$2; SEED=$3; GPU=${4:-auto}
7
+ REPO=/fsx/ajay-stu/Translation_Guided_Sandhi_Splitting_Experiment_Guide
8
+ NAME=$(basename "$CONFIG" .yaml)_seed${SEED}
9
+ LOG=$REPO/outputs/logs/${NAME}.log
10
+
11
+ if [ "$GPU" = "auto" ]; then
12
+ # Combine "no compute app" with "< 100 MiB" so a just-launched job counts busy.
13
+ GPU=$(ssh -o BatchMode=yes -o StrictHostKeyChecking=no "$NODE" \
14
+ 'python3 -c "
15
+ import subprocess
16
+ busy=set()
17
+ for l in subprocess.check_output([\"nvidia-smi\",\"--query-compute-apps=gpu_uuid\",\"--format=csv,noheader\"],text=True).splitlines():
18
+ busy.add(l.strip())
19
+ uuid={}
20
+ for l in subprocess.check_output([\"nvidia-smi\",\"--query-gpu=index,uuid,memory.used\",\"--format=csv,noheader,nounits\"],text=True).splitlines():
21
+ i,u,m=[x.strip() for x in l.split(\",\")]
22
+ if u not in busy and int(m)<100: print(i); break
23
+ "')
24
+ fi
25
+ if [ -z "$GPU" ]; then echo "NO FREE GPU on $NODE"; exit 1; fi
26
+ echo "node=$NODE gpu=$GPU config=$CONFIG seed=$SEED -> $LOG"
27
+
28
+ ssh -o BatchMode=yes -o StrictHostKeyChecking=no "$NODE" bash -lc "'
29
+ cd $REPO
30
+ export PYTHONNOUSERSITE=1 HF_HOME=/fsx/ajay-stu/hf_cache
31
+ export CUDA_VISIBLE_DEVICES=$GPU TOKENIZERS_PARALLELISM=false
32
+ nohup ./.conda-env/bin/python -I src/splitter/train.py \
33
+ --config $CONFIG --seed $SEED > $LOG 2>&1 &
34
+ echo started pid \$!
35
+ '"
scripts/run_baselines.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Baseline reproduction runs (guide: "Baseline: reproduce first").
3
+ # Re-checks GPU occupancy before each launch and refuses to crowd another user.
4
+ set -u
5
+ cd /fsx/ajay-stu/Translation_Guided_Sandhi_Splitting_Experiment_Guide
6
+ export PYTHONNOUSERSITE=1 HF_HOME=/fsx/ajay-stu/hf_cache TOKENIZERS_PARALLELISM=false
7
+ export OMP_NUM_THREADS=8
8
+ export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
9
+ SEED=${SEED:-13}
10
+ for CFG in base_1pct base_10pct base_100pct; do
11
+ BUSY=$(nvidia-smi --query-compute-apps=gpu_uuid --format=csv,noheader | sort -u | wc -l)
12
+ if [ "$BUSY" -gt 0 ]; then
13
+ echo "ABORT: $BUSY GPU(s) in use by another job on $(hostname); not crowding."
14
+ exit 2
15
+ fi
16
+ echo "=== $(date -Is) launching $CFG seed $SEED on $(hostname) ==="
17
+ ./.conda-env/bin/torchrun --nproc_per_node=8 --master_port=29571 \
18
+ src/splitter/train.py --config configs/$CFG.yaml --seed $SEED \
19
+ > logs/${CFG}_seed${SEED}.log 2>&1
20
+ rc=$?
21
+ echo "=== $(date -Is) $CFG finished rc=$rc ==="
22
+ [ $rc -ne 0 ] && { echo "FAILED $CFG"; tail -20 logs/${CFG}_seed${SEED}.log; exit $rc; }
23
+ done
24
+ echo "ALL BASELINES DONE $(date -Is)"