feat: auto-detect GPU in setup scripts, log environment at startup
- setup-windows.ps1 and setup_env.sh detect nvidia-smi for CUDA vs CPU PyTorch - Startup logs Python version, venv path, PyTorch/CUDA/GPU, scikit-learn, librosa Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2149,7 +2149,30 @@ class _KeyFilter(QObject):
|
|||||||
return super().eventFilter(obj, event)
|
return super().eventFilter(obj, event)
|
||||||
|
|
||||||
|
|
||||||
|
def _log_env():
|
||||||
|
"""Log Python environment info at startup."""
|
||||||
|
_log(f"Python {sys.version}")
|
||||||
|
_log(f"venv: {sys.prefix}")
|
||||||
|
try:
|
||||||
|
import torch
|
||||||
|
cuda = torch.cuda.get_device_name(0) if torch.cuda.is_available() else "not available"
|
||||||
|
_log(f"PyTorch {torch.__version__} — CUDA {torch.version.cuda or 'n/a'} — GPU: {cuda}")
|
||||||
|
except ImportError:
|
||||||
|
_log("PyTorch: not installed")
|
||||||
|
try:
|
||||||
|
import sklearn
|
||||||
|
_log(f"scikit-learn {sklearn.__version__}")
|
||||||
|
except ImportError:
|
||||||
|
_log("scikit-learn: not installed (training will fail)")
|
||||||
|
try:
|
||||||
|
import librosa
|
||||||
|
_log(f"librosa {librosa.__version__}")
|
||||||
|
except ImportError:
|
||||||
|
_log("librosa: not installed")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
_log_env()
|
||||||
# Force desktop OpenGL (not GLES) so mpv's render context produces non-black output.
|
# Force desktop OpenGL (not GLES) so mpv's render context produces non-black output.
|
||||||
# Must be set before QApplication.
|
# Must be set before QApplication.
|
||||||
from PyQt6.QtGui import QSurfaceFormat
|
from PyQt6.QtGui import QSurfaceFormat
|
||||||
|
|||||||
+9
-2
@@ -25,9 +25,16 @@ $hasTorch = python -c "import torch" 2>&1
|
|||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Host "`nPyTorch already installed, skipping." -ForegroundColor Green
|
Write-Host "`nPyTorch already installed, skipping." -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
Write-Host "`nInstalling PyTorch with CUDA 12.8..."
|
# Detect NVIDIA GPU via nvidia-smi
|
||||||
Write-Host "(For CPU-only: pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu)" -ForegroundColor Yellow
|
$hasNvidia = Get-Command nvidia-smi -ErrorAction SilentlyContinue
|
||||||
|
if ($hasNvidia) {
|
||||||
|
Write-Host "`nNVIDIA GPU detected — installing PyTorch with CUDA 12.8..." -ForegroundColor Green
|
||||||
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu128
|
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu128
|
||||||
|
} else {
|
||||||
|
Write-Host "`nNo NVIDIA GPU detected — installing CPU-only PyTorch..." -ForegroundColor Yellow
|
||||||
|
Write-Host "(Audio scanning will work but will be slower without GPU)" -ForegroundColor Yellow
|
||||||
|
pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# ── Python deps ───────────────────────────────────────────
|
# ── Python deps ───────────────────────────────────────────
|
||||||
|
|||||||
+7
-1
@@ -15,8 +15,14 @@ PYTHON_VERSION="3.12"
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
VENV_DIR="$SCRIPT_DIR/.venv"
|
VENV_DIR="$SCRIPT_DIR/.venv"
|
||||||
|
|
||||||
# CUDA version for PyTorch index URL
|
# Auto-detect GPU for PyTorch index URL
|
||||||
|
if command -v nvidia-smi &>/dev/null; then
|
||||||
TORCH_INDEX="https://download.pytorch.org/whl/cu128"
|
TORCH_INDEX="https://download.pytorch.org/whl/cu128"
|
||||||
|
echo "NVIDIA GPU detected — will install PyTorch with CUDA 12.8"
|
||||||
|
else
|
||||||
|
TORCH_INDEX="https://download.pytorch.org/whl/cpu"
|
||||||
|
echo "No NVIDIA GPU detected — will install CPU-only PyTorch"
|
||||||
|
fi
|
||||||
|
|
||||||
# ── Parse args ────────────────────────────────────────────────────────
|
# ── Parse args ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user