File size: 1,529 Bytes
f509251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Launch training on a remote node, pinning CUDA_VISIBLE_DEVICES.
# Usage: scripts/launch.sh <node-ip> <config> <seed> [gpu-index-or-auto]
# Default "auto" claims the first GPU with no compute processes.
set -euo pipefail
NODE=$1; CONFIG=$2; SEED=$3; GPU=${4:-auto}
REPO=/fsx/ajay-stu/Translation_Guided_Sandhi_Splitting_Experiment_Guide
NAME=$(basename "$CONFIG" .yaml)_seed${SEED}
LOG=$REPO/outputs/logs/${NAME}.log

if [ "$GPU" = "auto" ]; then
  # Combine "no compute app" with "< 100 MiB" so a just-launched job counts busy.
  GPU=$(ssh -o BatchMode=yes -o StrictHostKeyChecking=no "$NODE" \
    'python3 -c "
import subprocess
busy=set()
for l in subprocess.check_output([\"nvidia-smi\",\"--query-compute-apps=gpu_uuid\",\"--format=csv,noheader\"],text=True).splitlines():
    busy.add(l.strip())
uuid={}
for l in subprocess.check_output([\"nvidia-smi\",\"--query-gpu=index,uuid,memory.used\",\"--format=csv,noheader,nounits\"],text=True).splitlines():
    i,u,m=[x.strip() for x in l.split(\",\")]
    if u not in busy and int(m)<100: print(i); break
"')
fi
if [ -z "$GPU" ]; then echo "NO FREE GPU on $NODE"; exit 1; fi
echo "node=$NODE gpu=$GPU config=$CONFIG seed=$SEED  -> $LOG"

ssh -o BatchMode=yes -o StrictHostKeyChecking=no "$NODE" bash -lc "'
cd $REPO
export PYTHONNOUSERSITE=1 HF_HOME=/fsx/ajay-stu/hf_cache
export CUDA_VISIBLE_DEVICES=$GPU TOKENIZERS_PARALLELISM=false
nohup ./.conda-env/bin/python -I src/splitter/train.py \
    --config $CONFIG --seed $SEED > $LOG 2>&1 &
echo started pid \$!
'"