minhluanquach/unet-training-data / scripts /transfer_to_runpod.ps1
minhluanquach's picture
download
raw
7.46 kB
# ==============================================================
# Transfer Project to RunPod for SyncNet Training Resume
# ==============================================================
# PowerShell version — run directly from Windows.
# Uses scp/rsync via OpenSSH (built into Windows 10/11).
#
# USAGE:
# 1. Edit $RunPodIP and $RunPodPort below
# 2. Run: .\scripts\transfer_to_runpod.ps1
# 3. Or run a single step:
# .\scripts\transfer_to_runpod.ps1 -Step code
# .\scripts\transfer_to_runpod.ps1 -Step checkpoint
# .\scripts\transfer_to_runpod.ps1 -Step mel
# .\scripts\transfer_to_runpod.ps1 -Step processed
# .\scripts\transfer_to_runpod.ps1 -Step verify
# ==============================================================
param(
[ValidateSet("all", "code", "checkpoint", "mel", "processed", "verify")]
[string]$Step = "all"
)
# ========================
# CONFIGURE THESE VALUES
# ========================
$RunPodIP = if ($env:RUNPOD_IP) { $env:RUNPOD_IP } else { "" }
$RunPodPort = if ($env:RUNPOD_PORT) { $env:RUNPOD_PORT } else { "" }
$RemoteDest = "/workspace/Train_Advanced_Lipsync_Model"
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
if (-not $RunPodIP -or -not $RunPodPort) {
Write-Host "ERROR: Set your RunPod SSH connection details:" -ForegroundColor Red
Write-Host ""
Write-Host ' $env:RUNPOD_IP = "<your-pod-ip>"'
Write-Host ' $env:RUNPOD_PORT = "<your-pod-port>"'
Write-Host ' .\scripts\transfer_to_runpod.ps1'
exit 1
}
$SshTarget = "root@${RunPodIP}"
$SshOpts = @("-p", $RunPodPort, "-o", "StrictHostKeyChecking=no")
Write-Host "============================================"
Write-Host " Transfer to RunPod"
Write-Host "============================================"
Write-Host " Source: $ProjectRoot"
Write-Host " Target: ${SshTarget}:${RemoteDest}"
Write-Host " Port: $RunPodPort"
Write-Host "============================================"
function Transfer-Code {
Write-Host "`n[1/5] Transferring code, configs, and scripts..." -ForegroundColor Cyan
# Create remote directories
ssh @SshOpts $SshTarget "mkdir -p $RemoteDest/{checkpoints,data/{processed,cache},logs}"
# Use scp for key files/folders
$codeDirs = @("src", "configs", "scripts", "models", "tests", "docs", "guide", "learn")
$codeFiles = @("pyproject.toml", "README.md", "PLAN.md")
foreach ($dir in $codeDirs) {
$localPath = Join-Path $ProjectRoot $dir
if (Test-Path $localPath) {
Write-Host " Syncing $dir/..."
scp -r -P $RunPodPort $localPath "${SshTarget}:${RemoteDest}/"
}
}
foreach ($file in $codeFiles) {
$localPath = Join-Path $ProjectRoot $file
if (Test-Path $localPath) {
scp -P $RunPodPort $localPath "${SshTarget}:${RemoteDest}/"
}
}
Write-Host " Done — code synced." -ForegroundColor Green
}
function Transfer-Checkpoint {
Write-Host "`n[2/5] Transferring SyncNet checkpoint (~354 MB)..." -ForegroundColor Cyan
$checkpointPath = Join-Path $ProjectRoot "checkpoints\syncnet_best.pt"
if (-not (Test-Path $checkpointPath)) {
Write-Host " ERROR: $checkpointPath not found!" -ForegroundColor Red
return
}
scp -P $RunPodPort $checkpointPath "${SshTarget}:${RemoteDest}/checkpoints/"
Write-Host " Done — checkpoint synced." -ForegroundColor Green
}
function Transfer-Mel {
Write-Host "`n[3/5] Transferring mel spectrograms (~1.2 GB)..." -ForegroundColor Cyan
$cacheDir = Join-Path $ProjectRoot "data\cache"
$melFiles = Get-ChildItem $cacheDir -Recurse -Filter "mel_spectrogram.npy"
$total = $melFiles.Count
$i = 0
foreach ($mel in $melFiles) {
$i++
$videoName = $mel.Directory.Name
# Create remote cache dir for this video
ssh @SshOpts $SshTarget "mkdir -p $RemoteDest/data/cache/$videoName"
scp -P $RunPodPort $mel.FullName "${SshTarget}:${RemoteDest}/data/cache/${videoName}/"
Write-Host " [$i/$total] $videoName" -NoNewline
Write-Host " ✓" -ForegroundColor Green
}
Write-Host " Done — $total mel spectrograms synced." -ForegroundColor Green
}
function Transfer-Processed {
Write-Host "`n[4/5] Transferring processed data (~145 GB)..." -ForegroundColor Cyan
Write-Host " This is the LARGEST transfer. Consider running in a persistent session." -ForegroundColor Yellow
Write-Host " Tip: If interrupted, re-run this step — scp will overwrite, rsync will resume." -ForegroundColor Yellow
Write-Host ""
$processedDir = Join-Path $ProjectRoot "data\processed"
$videoDirs = Get-ChildItem $processedDir -Directory
$total = $videoDirs.Count
$i = 0
foreach ($dir in $videoDirs) {
$i++
Write-Host " [$i/$total] $($dir.Name)..." -NoNewline
scp -r -P $RunPodPort $dir.FullName "${SshTarget}:${RemoteDest}/data/processed/"
Write-Host " ✓" -ForegroundColor Green
}
Write-Host " Done — $total video directories synced." -ForegroundColor Green
}
function Verify-Transfer {
Write-Host "`n[5/5] Verifying transfer..." -ForegroundColor Cyan
ssh @SshOpts $SshTarget @"
cd $RemoteDest
echo '=== Checking files ==='
if [ -f pyproject.toml ]; then echo ' ✓ Code transferred'; else echo ' ✗ Code MISSING'; fi
if [ -f checkpoints/syncnet_best.pt ]; then
SIZE=\$(du -h checkpoints/syncnet_best.pt | cut -f1)
echo " ✓ Checkpoint: syncnet_best.pt (\$SIZE)"
else
echo ' ✗ Checkpoint MISSING'
fi
if [ -d data/processed ]; then
NUM=\$(find data/processed -maxdepth 1 -type d | wc -l)
echo " ✓ Processed: \$((NUM - 1)) video directories"
else
echo ' ✗ Processed data MISSING'
fi
if [ -d data/cache ]; then
MEL=\$(find data/cache -name 'mel_spectrogram.npy' | wc -l)
echo " ✓ Mel spectrograms: \$MEL files"
else
echo ' ✗ Cache/mel data MISSING'
fi
echo ''
echo '=== Disk usage ==='
du -sh data/processed/ data/cache/ checkpoints/ 2>/dev/null || true
df -h /workspace
"@
Write-Host ""
Write-Host "=== Ready? Run on the pod ===" -ForegroundColor Green
Write-Host " bash scripts/runpod_setup.sh"
Write-Host ' torchrun --nproc_per_node=$(python3 -c "import torch; print(torch.cuda.device_count())") \'
Write-Host " -m src.training.train_syncnet_distributed \"
Write-Host " --config configs/syncnet_distributed.yaml \"
Write-Host " --resume checkpoints/syncnet_best.pt"
}
# ========================
# MAIN
# ========================
switch ($Step) {
"code" { Transfer-Code }
"checkpoint" { Transfer-Checkpoint }
"mel" { Transfer-Mel }
"processed" { Transfer-Processed }
"verify" { Verify-Transfer }
"all" {
Transfer-Code
Transfer-Checkpoint
Transfer-Mel
Transfer-Processed
Verify-Transfer
Write-Host "`n============================================" -ForegroundColor Green
Write-Host " All transfers complete!" -ForegroundColor Green
Write-Host "============================================" -ForegroundColor Green
}
}

Xet Storage Details

Size:
7.46 kB
·
Xet hash:
4b8ce5088b8d84008a17588dfe3589840aae970ae91cc4942840c3d094fb11d9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.