#!/bin/bash #SBATCH --job-name=smhier-canary #SBATCH --account=torch_pr_375_cds #SBATCH --partition=h200_cds #SBATCH --gres=gpu:h200:1 #SBATCH --cpus-per-task=8 #SBATCH --mem=64G #SBATCH --time=01:30:00 #SBATCH --output=/scratch/ajc10180/repos/smooth-hierarchy/logs/canary-%j.out #SBATCH --error=/scratch/ajc10180/repos/smooth-hierarchy/logs/canary-%j.err set -euo pipefail REPO=/scratch/ajc10180/repos/smooth-hierarchy DATA=/scratch/ajc10180/data SHIM_DIR=$REPO/.shim SCRATCH_BASE=/scratch/ajc10180 mkdir -p "$REPO/logs" "$REPO/checkpoints" echo "[canary] $(date -u +%FT%TZ) starting on $(hostname)" nvidia-smi || echo "[canary] WARN: nvidia-smi unavailable" # ---- Scratch caches (match setup.sbatch) ---- export UV_CACHE_DIR="$SCRATCH_BASE/.uv-cache" export UV_PYTHON_INSTALL_DIR="$SCRATCH_BASE/.uv-python" export UV_TOOL_DIR="$SCRATCH_BASE/.uv-tool" export PIP_CACHE_DIR="$SCRATCH_BASE/.pip-cache" export HF_HOME="$SCRATCH_BASE/.hf-home" export TRANSFORMERS_CACHE="$HF_HOME" export TORCH_HOME="$SCRATCH_BASE/.torch-home" # ---- FFmpeg shared libs (for torchcodec) ---- FFMPEG_DIR="$SCRATCH_BASE/ffmpeg-shared" export LD_LIBRARY_PATH="$FFMPEG_DIR/lib:${LD_LIBRARY_PATH:-}" export PATH="$FFMPEG_DIR/bin:$PATH" # ---- NVIDIA lib dirs from torch wheel (for torchcodec CUDA NPP etc.) ---- NVLIBS="" for d in "$REPO"/.venv/lib/python3.10/site-packages/nvidia/*/lib; do [[ -d "$d" ]] && NVLIBS="$d:$NVLIBS" done export LD_LIBRARY_PATH="${NVLIBS}$LD_LIBRARY_PATH" echo "[canary] NVIDIA libs: $(echo $NVLIBS | tr ':' '\n' | wc -l) dirs" # ---- uv on PATH + reuse existing venv ---- export PATH="$HOME/.local/bin:$PATH" cd "$REPO" command -v uv uv --version # ---- W&B + HF keys via KeyHandler ---- WORKSPACE=/scratch/ajc10180/repos/smooth-hierarchy # KeyHandler lives in the workspace .tools-venv; source env by running a short python snippet locally. # But on cluster we don't have workspace .tools-venv — export via cluster ~/.raca if present, else expect env. if [[ -f "$HOME/.raca/keys.env" ]]; then # shellcheck disable=SC1091 . "$HOME/.raca/keys.env" fi : "${WANDB_API_KEY:?WANDB_API_KEY not set — export before sbatch or put in ~/.raca/keys.env}" echo "[canary] WANDB_API_KEY: ${WANDB_API_KEY:0:10}..." # ---- Verify torchcodec now loads on GPU node (the thing setup couldn't verify on CPU) ---- ./.venv/bin/python -c " import torch print('torch', torch.__version__, 'cuda avail:', torch.cuda.is_available(), 'device:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'cpu') import torchcodec print('torchcodec', torchcodec.__version__) from torchcodec.decoders import VideoDecoder import glob vids = sorted(glob.glob('/scratch/ajc10180/data/ucf101/*/*.avi'))[:1] d = VideoDecoder(vids[0]) f = d[0] print('decoded shape:', tuple(f.shape), 'dtype:', f.dtype, 'n_frames:', d.metadata.num_frames) print('GPU SMOKE TEST OK') " # ---- Canary training run ---- # Per EXPERIMENT_README.md canary spec: # 1 GPU, ~1 hr, --limit_train_batches 200 for 2 epochs # image_size 64, batch_size 128 (README validated) # Verify: checkpoints save, W&B logs 4 loss components, recon panels at beta in {0, 0.1, 0.5, 0.9, 1.0} echo "[canary] $(date -u +%FT%TZ) launching train.py" ./.venv/bin/python -u train.py \ --data_root "$DATA/ucf101" \ --annotation_path "$DATA/ucf101_annotations" \ --dataset ucf101 \ --image_size 64 \ --batch_size 128 \ --num_workers 8 \ --max_epochs 2 \ --limit_train_batches 200 \ --checkpoint_dir "$REPO/checkpoints/canary-${SLURM_JOB_ID}" \ --checkpoint_every_n_train_steps 100 \ --wandb_project smooth-hierarchy \ --wandb_run_name "canary-${SLURM_JOB_ID}" \ --wandb_tags canary,ucf101,image64 \ --wandb_notes "smooth-hierarchy-ucf101 canary: 2 epochs x 200 batches to verify pipeline" \ --wandb_log_images_every 50 \ --accelerator gpu \ --devices 1 echo "[canary] $(date -u +%FT%TZ) DONE" ls -la "$REPO/checkpoints/canary-${SLURM_JOB_ID}/" || true