Buckets:
| # ============================================================== | |
| # Google Cloud VM Setup Script for LipSync Training | |
| # ============================================================== | |
| # Run this once after SSH-ing into your GCP VM. | |
| # | |
| # Prerequisites: | |
| # - GCP VM with GPU (T4 or L4) already created | |
| # - Data already transferred to the VM | |
| # | |
| # Usage: | |
| # cd ~/Train_Advanced_Lipsync_Model | |
| # bash scripts/gcp/gcp_setup.sh | |
| # ============================================================== | |
| set -e | |
| echo "============================================" | |
| echo " GCP VM Setup for Advanced LipSync Model" | |
| echo "============================================" | |
| # --- System Dependencies --- | |
| echo "" | |
| echo "[1/7] Installing system dependencies..." | |
| sudo apt-get update -qq | |
| sudo apt-get install -y -qq ffmpeg libsndfile1 git-lfs tmux htop > /dev/null 2>&1 | |
| echo " ✓ ffmpeg, libsndfile, git-lfs, tmux, htop installed" | |
| # --- Python Environment --- | |
| echo "" | |
| echo "[2/7] Setting up Python environment..." | |
| if [ ! -d "venv" ]; then | |
| python3 -m venv venv | |
| echo " ✓ Virtual environment created" | |
| else | |
| echo " ✓ Virtual environment already exists" | |
| fi | |
| source venv/bin/activate | |
| pip install --upgrade pip -q | |
| # --- Python Dependencies --- | |
| echo "" | |
| echo "[3/7] Installing Python dependencies..." | |
| pip install -e ".[dev]" -q | |
| pip install -U huggingface_hub -q | |
| echo " ✓ Python dependencies + huggingface_hub installed" | |
| # --- Verify GPU Setup --- | |
| echo "" | |
| echo "[4/7] Verifying GPU setup..." | |
| python3 -c " | |
| import torch | |
| num_gpus = torch.cuda.device_count() | |
| print(f' PyTorch version: {torch.__version__}') | |
| print(f' CUDA available: {torch.cuda.is_available()}') | |
| print(f' CUDA version: {torch.version.cuda}') | |
| print(f' Number of GPUs: {num_gpus}') | |
| for i in range(num_gpus): | |
| props = torch.cuda.get_device_properties(i) | |
| print(f' GPU {i}: {props.name} ({props.total_memory / 1024**3:.1f} GB)') | |
| " | |
| # --- Verify Dataset --- | |
| echo "" | |
| echo "[5/7] Checking dataset..." | |
| if [ -d "data/processed" ]; then | |
| NUM_VIDEOS=$(find data/processed -maxdepth 1 -type d | wc -l) | |
| echo " ✓ Found $((NUM_VIDEOS - 1)) video directories in data/processed/" | |
| else | |
| echo " ⚠ data/processed/ not found!" | |
| echo " Transfer from GCS: gsutil -m rsync -r gs://YOUR_BUCKET/data/processed/ data/processed/" | |
| fi | |
| if [ -d "data/cache" ]; then | |
| NUM_CACHE=$(find data/cache -maxdepth 1 -type d | wc -l) | |
| echo " ✓ Found $((NUM_CACHE - 1)) cached directories in data/cache/" | |
| else | |
| echo " ⚠ data/cache/ not found — you may need to run feature extraction" | |
| fi | |
| # --- Verify Checkpoints --- | |
| echo "" | |
| echo "[6/7] Checking checkpoints..." | |
| if [ -f "checkpoints/syncnet_best.pt" ]; then | |
| SIZE=$(du -h checkpoints/syncnet_best.pt | cut -f1) | |
| echo " ✓ Found syncnet_best.pt ($SIZE)" | |
| python3 -c " | |
| import torch | |
| ckpt = torch.load('checkpoints/syncnet_best.pt', map_location='cpu', weights_only=False) | |
| print(f' Epoch: {ckpt.get(\"epoch\", \"unknown\")}') | |
| print(f' Val loss: {ckpt.get(\"val_loss\", \"unknown\")}') | |
| " | |
| else | |
| echo " ⚠ checkpoints/syncnet_best.pt not found!" | |
| echo " Transfer from GCS: gsutil cp gs://YOUR_BUCKET/checkpoints/syncnet_best.pt checkpoints/" | |
| fi | |
| # --- Create working directories --- | |
| echo "" | |
| echo "[7/7] Creating working directories..." | |
| mkdir -p checkpoints logs data/processed data/cache | |
| echo " ✓ Directories ready" | |
| # --- Summary --- | |
| echo "" | |
| echo "============================================" | |
| echo " Setup Complete!" | |
| echo "============================================" | |
| echo "" | |
| echo "Next steps:" | |
| echo "" | |
| echo " 1. If data not transferred yet, use GCS:" | |
| echo " gsutil -m rsync -r gs://YOUR_BUCKET/data/ data/" | |
| echo "" | |
| echo " 2. Start training in tmux:" | |
| echo " tmux new -s train" | |
| echo " source venv/bin/activate" | |
| echo " python -m src.training.train_model --config configs/train_gcp.yaml" | |
| echo "" | |
| echo " 3. To resume from a checkpoint:" | |
| echo " Edit configs/train_gcp.yaml → training.resume_from = 'checkpoints/best_model.pt'" | |
| echo " python -m src.training.train_model --config configs/train_gcp.yaml" | |
| echo "" | |
| echo " 4. Monitor with TensorBoard:" | |
| echo " tensorboard --logdir logs --bind_all --port 6006" | |
| echo "" | |
| echo " 5. When done, download checkpoints:" | |
| echo " gsutil -m cp -r checkpoints/ gs://YOUR_BUCKET/checkpoints/" | |
| echo "" | |
Xet Storage Details
- Size:
- 4.31 kB
- Xet hash:
- 4c35adad5e12aafe0db5a63f319d4426d32f3c759ef75bd5009a0cc03618bc2a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.