Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
PR: Fix/cuda minimum check and abort (#4517)
Leo Borcherding96edad9c955b
diff --git a/studio/setup.ps1 b/studio/setup.ps1index 7091920ab94..77632d6bc21 100644--- a/studio/setup.ps1+++ b/studio/setup.ps1@@ -969,6 +969,67 @@ Write-Host "[OK] Using $PythonCmd ($(& $PythonCmd --version 2>&1))" -ForegroundC# Always create a .venv for isolation -- even for pip installs.# Created in the repo root (parent of studio/).$VenvDir = Join-Path $env:USERPROFILE ".unsloth\studio\.venv"++# Stale-venv detection: if the venv exists but its torch flavor no longer+# matches the current machine, wipe it so we get a clean install.+if (Test-Path $VenvDir -PathType Container) {+ $VenvPyExe = Join-Path $VenvDir "Scripts\python.exe"+ $installedTorchTag = $null+ $shouldRebuild = $false++ if (Test-Path $VenvPyExe) {+ try {+ $psi = New-Object System.Diagnostics.ProcessStartInfo+ $psi.FileName = $VenvPyExe+ $psi.Arguments = '-c "import torch; print(torch.__version__)"'+ $psi.RedirectStandardOutput = $true+ $psi.RedirectStandardError = $true+ $psi.UseShellExecute = $false+ $psi.CreateNoWindow = $true+ $proc = [System.Diagnostics.Process]::Start($psi)+ $torchVer = $proc.StandardOutput.ReadToEnd().Trim()+ $finished = $proc.WaitForExit(30000)+ if ($finished -and $proc.ExitCode -eq 0 -and $torchVer) {+ if ($torchVer -match '\+(cu\d+)') {+ $installedTorchTag = $Matches[1]+ } elseif ($torchVer -match '\+cpu') {+ $installedTorchTag = "cpu"+ } else {+ # Untagged wheel (plain "2.x.y" from PyPI) -- treat as cpu+ $installedTorchTag = "cpu"+ }+ } else {+ if (-not $finished) { try { $proc.Kill() } catch {} }+ $shouldRebuild = $true+ }+ } catch {+ $shouldRebuild = $true+ }+ } else {+ # Missing python.exe means the venv is incomplete -- rebuild it.+ $shouldRebuild = $true+ }++ if (-not $shouldRebuild) {+ $expectedTorchTag = if ($HasNvidiaSmi) { Get-PytorchCudaTag } else { "cpu" }+ if ($installedTorchTag -and $installedTorchTag -ne $expectedTorchTag) {+ $shouldRebuild = $true+ }+ }++ if ($shouldRebuild) {+ $reason = if ($installedTorchTag) { "torch $installedTorchTag != required $expectedTorchTag" } else { "torch could not be imported" }+ Write-Host " [INFO] Stale venv detected ($reason) -- rebuilding..." -ForegroundColor Yellow+ try {+ Remove-Item $VenvDir -Recurse -Force -ErrorAction Stop+ } catch {+ Write-Host " [ERROR] Could not remove stale venv: $($_.Exception.Message)" -ForegroundColor Red+ Write-Host " Close any running Studio/Python processes and re-run setup." -ForegroundColor Red+ exit 1+ }+ }+}+if (-not (Test-Path $VenvDir)) {Write-Host " Creating virtual environment at $VenvDir..." -ForegroundColor Cyan& $PythonCmd -m venv $VenvDir