-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain-student.slurm
More file actions
138 lines (120 loc) Β· 5.07 KB
/
Copy pathtrain-student.slurm
File metadata and controls
138 lines (120 loc) Β· 5.07 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#SBATCH --job-name=tiger-train
# Override job name with: sbatch --job-name=<name> train.slurm
#SBATCH --partition=studentkillable
#SBATCH --account=gpu-students
#SBATCH --time=24:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --mem=32G
#SBATCH --gres=gpu:8
#SBATCH --output=logs/train.%j.log
#SBATCH --error=logs/train.%j.log
#SBATCH --export=ALL
set -euo pipefail
cd /home/yandex/APDL2526a/$USER/TIGER-plus
echo "=== Job Parameters ==="
echo "SLURM_JOB_ID = ${SLURM_JOB_ID:-N/A}"
echo "SLURM_NODELIST = ${SLURM_NODELIST:-N/A}"
echo "User = $USER"
echo "Working directory = $(pwd)"
echo "GPUs requested = ${SLURM_GPUS:-4}"
echo "Started at = $(date)"
echo "======================"
mkdir -p logs
# ββ Environment setup ββ
# Use local /tmp for temp files to avoid NFS cleanup errors
export TMPDIR="$PWD/.tmp-${SLURM_JOB_ID:-$$}"
mkdir -p "$TMPDIR"
export TMP="$TMPDIR"
export TEMP="$TMPDIR"
export HF_HOME="$PWD/.hf_cache"
export HF_DATASETS_CACHE="$HF_HOME/datasets"
export HUGGINGFACE_HUB_CACHE="$HF_HOME/hub"
export TORCH_HOME="$PWD/.torch_cache"
mkdir -p "$TORCH_HOME"
export PYTHONUNBUFFERED=1
export TOKENIZERS_PARALLELISM=false
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
# ββ Auto-resubmit: preserve original job ID across continuation jobs ββ
export TIGER_ORIGINAL_JOB_ID="${TIGER_ORIGINAL_JOB_ID:-${SLURM_JOB_ID}}"
export TIGER_JOB_NAME="${TIGER_JOB_NAME:-${SLURM_JOB_NAME:-tiger-train}}"
export TIGER_PARTITION="${TIGER_PARTITION:-${SLURM_JOB_PARTITION:-killable}}"
export TIGER_ACCOUNT="${TIGER_ACCOUNT:-${SLURM_JOB_ACCOUNT:-}}"
export TIGER_NODELIST="${TIGER_NODELIST:-}"
# Stop 30min before 24h wall time so checkpoint can be saved (23h = 82800s)
export TIGER_TIME_LIMIT_SECS="${TIGER_TIME_LIMIT_SECS:-82800}"
echo "TIGER_ORIGINAL_JOB_ID = $TIGER_ORIGINAL_JOB_ID"
echo "TIGER_PARTITION = $TIGER_PARTITION"
echo "TIGER_TIME_LIMIT_SECS = $TIGER_TIME_LIMIT_SECS"
# ββ Load .env (contains WANDB_API_KEY, HUGGINGFACE_HUB_TOKEN) ββ
if [[ -f .env ]]; then
set -a && source .env && set +a
fi
# ββ W&B setup ββ
export WANDB_PROJECT="${WANDB_PROJECT:-tiger-plus}"
export WANDB_ENTITY="${WANDB_ENTITY:-selective-entropy-knowledge-distillation}"
export WANDB_DIR="$PWD/.wandb"
mkdir -p "$WANDB_DIR"
export WANDB_CACHE_DIR="$PWD/.wandb_cache"
mkdir -p "$WANDB_CACHE_DIR"
export WANDB_DATA_DIR="$PWD/.wandb_data"
mkdir -p "$WANDB_DATA_DIR"
export WANDB_MODE="${WANDB_MODE:-online}"
# ββ Python venv ββ
# Two venvs live in the project dir:
# ./venv3_12 - built on Python 3.12 (e.g. c-005)
# ./venv - built on Python 3.10 (SLURM nodes)
# Try venv3_12 first, then venv. If neither works, build ./venv for this node.
PY=""
for CANDIDATE in "$PWD/venv3_12/bin/python" "$PWD/venv/bin/python"; do
if [[ -x "$CANDIDATE" ]] && "$CANDIDATE" -c "import torch; assert torch.cuda.is_available()" 2>/dev/null; then
PY="$CANDIDATE"
break
fi
done
if [[ -z "$PY" ]]; then
echo "No working venv found. Building ./venv for $(python3 -V 2>&1)..."
rm -rf "$PWD/venv"
python3 -m venv --without-pip "$PWD/venv"
curl -sS https://bootstrap.pypa.io/get-pip.py | "$PWD/venv/bin/python"
"$PWD/venv/bin/python" -m pip install --upgrade pip wheel "setuptools<81"
# Install requirements excluding pip-system-certs (it corrupts pip's CA
# bundle mid-install, causing TLS errors on fresh venvs)
"$PWD/venv/bin/python" -m pip install --no-cache-dir --prefer-binary \
--extra-index-url https://download.pytorch.org/whl/cu124 \
$(grep -v '^pip-system-certs' "$PWD/requirements.txt" | tr '\n' ' ')
PY="$PWD/venv/bin/python"
fi
# ββ 8-GPU DDP setup ββ
# Disable P2P in case GPUs span different PCIe bridges (safe on all GPU types)
export NCCL_P2P_DISABLE=1
export NCCL_SHM_DISABLE=0
export NCCL_NVML_DISABLE=1
# ββ Config file ββ
CONFIG_FILE="${CONFIG_FILE:-configs/tiger-echoset-8gpu.yml}"
echo "=== TIGER Training (DDP) ==="
echo "Python: $PY ($($PY -V 2>&1))"
echo "Config: $CONFIG_FILE"
echo "CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES:-not set}"
echo "NCCL_P2P_DISABLE=$NCCL_P2P_DISABLE"
echo "TMPDIR: $TMPDIR (local, avoids NFS errors)"
echo "=============================="
# ββ Download dataset if needed ββ
if [[ ! -f "DataPreProcess/EchoSet/train/mix.json" ]]; then
echo "Dataset not found, downloading EchoSet from HuggingFace..."
$PY download_datasets.py --datasets echoset
fi
# ββ Unset SLURM env vars so Lightning handles DDP spawning internally ββ
# Lightning auto-detects SLURM and limits to SLURM_NTASKS processes.
# Since we want Lightning to spawn DDP workers (not srun), clear these.
SAVED_CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES}"
export SLURM_JOB_ID_SAVED="${SLURM_JOB_ID}"
for v in SLURM_NTASKS SLURM_JOB_NAME SLURM_LOCALID SLURM_PROCID SLURM_NODEID SLURM_JOB_ID; do
unset "$v"
done
export CUDA_VISIBLE_DEVICES="$SAVED_CUDA_VISIBLE_DEVICES"
# ββ Launch training (Lightning handles DDP spawning - no torchrun) ββ
$PY audio_train.py --conf_dir "$CONFIG_FILE"
echo "=== Training finished at $(date) ==="
echo "SUCCESS: Training complete!"