diff --git a/main.py b/main.py index 3f43948..7eed29b 100755 --- a/main.py +++ b/main.py @@ -2149,7 +2149,30 @@ class _KeyFilter(QObject): 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(): + _log_env() # Force desktop OpenGL (not GLES) so mpv's render context produces non-black output. # Must be set before QApplication. from PyQt6.QtGui import QSurfaceFormat diff --git a/setup-windows.ps1 b/setup-windows.ps1 index 495ab2f..78a53bc 100644 --- a/setup-windows.ps1 +++ b/setup-windows.ps1 @@ -25,9 +25,16 @@ $hasTorch = python -c "import torch" 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "`nPyTorch already installed, skipping." -ForegroundColor Green } else { - Write-Host "`nInstalling PyTorch with CUDA 12.8..." - Write-Host "(For CPU-only: pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu)" -ForegroundColor Yellow - pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu128 + # Detect NVIDIA GPU via nvidia-smi + $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 + } 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 ─────────────────────────────────────────── diff --git a/setup_env.sh b/setup_env.sh index f888830..f256663 100755 --- a/setup_env.sh +++ b/setup_env.sh @@ -15,8 +15,14 @@ PYTHON_VERSION="3.12" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" VENV_DIR="$SCRIPT_DIR/.venv" -# CUDA version for PyTorch index URL -TORCH_INDEX="https://download.pytorch.org/whl/cu128" +# Auto-detect GPU for PyTorch index URL +if command -v nvidia-smi &>/dev/null; then + 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 ────────────────────────────────────────────────────────