Spaces:
Running
Running
| ο»Ώ# Safe Dependency Installation Script for Windows | |
| # Handles problematic packages like flash-attn carefully | |
| Write-Host "π OmniAvatar Dependency Installation" -ForegroundColor Green | |
| Write-Host "====================================" -ForegroundColor Green | |
| # Function to run pip command safely | |
| function Install-Package { | |
| param( | |
| [string[]]$Command, | |
| [string]$Description, | |
| [bool]$Optional = $false | |
| ) | |
| Write-Host "π $Description" -ForegroundColor Yellow | |
| try { | |
| $result = & $Command[0] $Command[1..$Command.Length] | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host "β $Description - Success" -ForegroundColor Green | |
| return $true | |
| } else { | |
| throw "Command failed with exit code $LASTEXITCODE" | |
| } | |
| } catch { | |
| if ($Optional) { | |
| Write-Host "β οΈ $Description - Failed (optional): $($_.Exception.Message)" -ForegroundColor Yellow | |
| return $false | |
| } else { | |
| Write-Host "β $Description - Failed: $($_.Exception.Message)" -ForegroundColor Red | |
| throw | |
| } | |
| } | |
| } | |
| try { | |
| # Step 1: Upgrade pip and essential tools | |
| Install-Package -Command @("python", "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel", "packaging") -Description "Upgrading pip and build tools" | |
| # Step 2: Install PyTorch with CUDA support (if available) | |
| Write-Host "π¦ Installing PyTorch..." -ForegroundColor Cyan | |
| try { | |
| Install-Package -Command @("python", "-m", "pip", "install", "torch", "torchvision", "torchaudio", "--index-url", "https://download.pytorch.org/whl/cu124") -Description "Installing PyTorch with CUDA support" | |
| } catch { | |
| Write-Host "β οΈ CUDA PyTorch failed, installing CPU version" -ForegroundColor Yellow | |
| Install-Package -Command @("python", "-m", "pip", "install", "torch", "torchvision", "torchaudio") -Description "Installing PyTorch CPU version" | |
| } | |
| # Step 3: Install main requirements | |
| Install-Package -Command @("python", "-m", "pip", "install", "-r", "requirements.txt") -Description "Installing main requirements" | |
| # Step 4: Try optional performance packages | |
| Write-Host "π― Installing optional performance packages..." -ForegroundColor Cyan | |
| # Try xformers | |
| Install-Package -Command @("python", "-m", "pip", "install", "xformers") -Description "Installing xformers (memory efficient attention)" -Optional $true | |
| # Flash-attn is often problematic, so we'll skip it by default | |
| Write-Host "βΉοΈ Skipping flash-attn installation (often problematic on Windows)" -ForegroundColor Blue | |
| Write-Host "π‘ You can try installing it later with: pip install flash-attn --no-build-isolation" -ForegroundColor Blue | |
| # Step 5: Verify installation | |
| Write-Host "π Verifying installation..." -ForegroundColor Cyan | |
| python -c @" | |
| import sys | |
| try: | |
| import torch | |
| import transformers | |
| import gradio | |
| import fastapi | |
| print(f'β PyTorch: {torch.__version__}') | |
| print(f'β Transformers: {transformers.__version__}') | |
| print(f'β Gradio: {gradio.__version__}') | |
| if torch.cuda.is_available(): | |
| print(f'β CUDA: {torch.version.cuda}') | |
| print(f'β GPU Count: {torch.cuda.device_count()}') | |
| else: | |
| print('βΉοΈ CUDA not available - will use CPU') | |
| # Check optional packages | |
| try: | |
| import xformers | |
| print(f'β xformers: {xformers.__version__}') | |
| except ImportError: | |
| print('βΉοΈ xformers not available (optional)') | |
| try: | |
| import flash_attn | |
| print('β flash_attn: Available') | |
| except ImportError: | |
| print('βΉοΈ flash_attn not available (optional)') | |
| print('π Installation verification successful!') | |
| except ImportError as e: | |
| print(f'β Installation verification failed: {e}') | |
| sys.exit(1) | |
| "@ | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host "" | |
| Write-Host "π Installation completed successfully!" -ForegroundColor Green | |
| Write-Host "" | |
| Write-Host "π‘ Next steps:" -ForegroundColor Yellow | |
| Write-Host "1. Download models: .\setup_omniavatar.ps1" -ForegroundColor White | |
| Write-Host "2. Start the app: python app.py" -ForegroundColor White | |
| Write-Host "" | |
| } else { | |
| throw "Installation verification failed" | |
| } | |
| } catch { | |
| Write-Host "" | |
| Write-Host "β Installation failed: $($_.Exception.Message)" -ForegroundColor Red | |
| Write-Host "" | |
| Write-Host "π‘ Troubleshooting tips:" -ForegroundColor Yellow | |
| Write-Host "1. Make sure Python 3.8+ is installed" -ForegroundColor White | |
| Write-Host "2. Try running in a virtual environment" -ForegroundColor White | |
| Write-Host "3. Check your internet connection" -ForegroundColor White | |
| Write-Host "4. For GPU support, ensure CUDA is properly installed" -ForegroundColor White | |
| exit 1 | |
| } | |