Spaces:
Running
Running
File size: 4,945 Bytes
dcf0937 |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
ο»Ώ# 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
}
|