# Quick configuration switcher for HF Spaces deployment # Usage: .\switch_hf_config.ps1 [minimal|small-gpu|medium-gpu] param( [Parameter(Mandatory=$false)] [ValidateSet('minimal', 'small-gpu', 'medium-gpu')] [string]$Config ) if (-not $Config) { Write-Host "Usage: .\switch_hf_config.ps1 [minimal|small-gpu|medium-gpu]" Write-Host "" Write-Host "Options:" Write-Host " minimal - CPU only, fastest deployment (recommended)" Write-Host " small-gpu - T4 Small GPU, good balance" Write-Host " medium-gpu - T4 Medium GPU, full preloading (Pro/Enterprise)" Write-Host "" exit 1 } switch ($Config) { 'minimal' { Write-Host "🔧 Switching to MINIMAL configuration (CPU-only)..." -ForegroundColor Cyan $content = @" runtime: docker sdk: docker python_version: "3.10" build: dockerfile: Dockerfile.hf-spaces-minimal cache: true env: - HF_SPACES=true - FAST_MODE=true - PRELOAD_GGUF=false - PRELOAD_SMALL_MODELS=false "@ Set-Content -Path ".huggingface.yaml" -Value $content Write-Host "✅ Configuration updated to CPU-only mode" -ForegroundColor Green Write-Host "📝 This will deploy on the free tier (no GPU)" -ForegroundColor Yellow Write-Host "⚡ Build time: ~5-10 minutes" -ForegroundColor Yellow } 'small-gpu' { Write-Host "🔧 Switching to SMALL GPU configuration (T4 Small)..." -ForegroundColor Cyan $content = @" runtime: docker sdk: docker python_version: "3.10" build: dockerfile: Dockerfile.hf-spaces-minimal cache: true hardware: gpu: t4-small env: - HF_SPACES=true - FAST_MODE=true - PRELOAD_GGUF=false - PRELOAD_SMALL_MODELS=false - CUDA_VISIBLE_DEVICES=0 - PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128 "@ Set-Content -Path ".huggingface.yaml" -Value $content Write-Host "✅ Configuration updated to T4 Small GPU" -ForegroundColor Green Write-Host "📝 Requires GPU access in your HF account" -ForegroundColor Yellow Write-Host "⚡ Build time: ~10-15 minutes" -ForegroundColor Yellow } 'medium-gpu' { Write-Host "🔧 Switching to MEDIUM GPU configuration (T4 Medium + Preloading)..." -ForegroundColor Cyan $content = @" runtime: docker sdk: docker python_version: "3.10" build: dockerfile: Dockerfile.hf-spaces cache: true hardware: gpu: t4-medium env: - SPACE_ID=`$SPACE_ID - HF_HOME=/app/.cache/huggingface - TORCH_HOME=/app/.cache/torch - MODEL_CACHE_DIR=/app/models - PRELOAD_GGUF=true - HF_SPACES=true - CUDA_VISIBLE_DEVICES=0 - PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 "@ Set-Content -Path ".huggingface.yaml" -Value $content Write-Host "✅ Configuration updated to T4 Medium GPU with preloading" -ForegroundColor Green Write-Host "📝 Requires Pro/Enterprise tier" -ForegroundColor Yellow Write-Host "⚡ Build time: ~20-30 minutes (first time), instant startup" -ForegroundColor Yellow } } Write-Host "" Write-Host "📋 Next steps:" -ForegroundColor Cyan Write-Host " 1. Review the changes: git diff .huggingface.yaml" Write-Host " 2. Commit: git commit -am 'Switch to $Config configuration'" Write-Host " 3. Push: git push" Write-Host " 4. Monitor your Space build logs" Write-Host "" Write-Host "🔍 Check status at: https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE" -ForegroundColor Yellow