video_monitor/scripts/enable-gpu.ps1
2026-09-04 18:16:14 +08:00

14 lines
816 B
PowerShell

$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$python = Join-Path $root '.venv\Scripts\python.exe'
if (-not (Test-Path -LiteralPath $python)) {
throw "Python virtual environment not found: $python"
}
& $python -m pip install --upgrade --force-reinstall --no-deps `
torch==2.8.0+cu129 torchvision==0.23.0+cu129 `
--index-url https://download.pytorch.org/whl/cu129
if ($LASTEXITCODE -ne 0) { throw 'CUDA PyTorch installation failed' }
& $python -c "import torch; assert torch.cuda.is_available(), 'CUDA is unavailable'; print(torch.__version__, torch.version.cuda, torch.cuda.get_device_name(0))"
if ($LASTEXITCODE -ne 0) { throw 'CUDA verification failed' }
Write-Host 'GPU inference runtime is ready. Restart Monitor and select CUDA for the YOLO model.' -ForegroundColor Green