File size: 3,044 Bytes
adabee1 | 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 | #!/usr/bin/env bash
# Edge-trimmed data (scripts/trim_edges.py -> data/coral_da_trim) through the alignment
# pipeline, then the same training recipe as runs/v2-en-gan / runs/v3-en-gan: only the
# data differs. Run detached, one per frontend:
# docker compose run -d --name tiny-voca-dk-trim-v2 kit bash scripts/trim_chain.sh v2
# docker compose run -d --name tiny-voca-dk-trim-v3 kit-v3 bash scripts/trim_chain.sh v3
# v2 builds the wav2vec2 caches on GPU 0 (v2's adapt_head cannot reuse); v3 reuses them.
# GPUs are fixed per variant so the two never race: v2 trains on GPU 1 once the
# untrimmed v3 run pauses at PAUSE_V3_AT (STOP file, resumable); v3 trains on GPU 0 once
# the vocoder has been stopped (host side, after its next checkpoint save).
set -uo pipefail
cd /opt/kit
variant="${1:?v2|v3}"
export DATA=data/coral_da_trim WORKERS="${WORKERS:-6}" THREADS="${THREADS:-8}"
V2_LOG=checks/trim-chain.log
stamp() { echo "== stage $1 $(date -u +%FT%TZ)"; }
run() { stamp "$1"; CUDA_VISIBLE_DEVICES=0 bash scripts/gpu_pipeline.sh "$1" || { echo "exit=1 stage=$1"; exit 1; }; }
wait_for() { # log, pattern; gives up if that chain failed
until grep -q "$2" "$1" 2>/dev/null; do
grep -q "^exit=1" "$1" 2>/dev/null && { echo "exit=1 waiting for $1"; exit 1; }
sleep 60; done; }
wait_gpu() { # device index; ~11 GB is used in the GAN phase
until CUDA_VISIBLE_DEVICES=$1 python -c "import sys, torch; sys.exit(0 if torch.cuda.mem_get_info(0)[0] > 13e9 else 1)" 2>/dev/null
do sleep 120; done; }
train() { # device, run dir, initialization
stamp "wait-gpu$1"; wait_gpu "$1"
stamp train
CUDA_VISIBLE_DEVICES=$1 RUN=$2 STEPS=100000 INITIALIZATION=$3 bash scripts/gpu_pipeline.sh train-adapt > "$2.log" 2>&1 \
|| { echo "exit=1 stage=train"; exit 1; }
echo exit=0; }
case "$variant" in
v2)
export TAG=trim FEAT=data/trim-features
for s in check-data features cache fit calibrate evaluate test export pack; do run "$s"; done
PAUSE_V3_AT="${PAUSE_V3_AT:-30000}"
stamp "pause-v3-at-$PAUSE_V3_AT"
until python -c "import json, sys; sys.exit(0 if json.loads(open('runs/v3-en-gan/metrics.jsonl').readlines()[-1])['step'] >= $PAUSE_V3_AT else 1)"
do sleep 60; done
touch runs/v3-en-gan/STOP
train 1 runs/v2trim-en-gan models/da-initialized-gpu.pt ;;
v3)
export TAG=v3trim FEAT=data/v3trim-features
export CACHE_REUSE=work/trim-head-cache CACHE_REUSE_TEST=work/trim-head-test-cache
# No check-data: kit-v3's check_data.py flags 595 normalized-text keys of the v2-made
# preparation (identical on data/coral_da, checks/v3-data-untrimmed.json), and the
# original v3 run skipped it too. The v2 chain checks the same trimmed files.
run features
stamp wait-v2-cache; wait_for "$V2_LOG" "^== stage fit"
for s in cache fit calibrate evaluate; do run "$s"; done
stamp wait-v2-test-cache; wait_for "$V2_LOG" "^== stage export"
for s in test export pack; do run "$s"; done
train 0 runs/v3trim-en-gan models/da-v3-initialized-en-gpu.pt ;;
esac
|