# Quick Rebuild for GPU (After CUDA 13.0 Installation)

## 🚀 Fast Track - 3 Commands

Once CUDA 13.0 Update 2 installation finishes:

### 1. Close and Reopen Terminal
**Important:** Close ALL PowerShell/Terminal windows and open a **NEW** one to get updated environment variables.

### 2. Navigate to Project
```powershell
cd C:\code\whisper.cpp
```

### 3. Clean Build with GPU
```powershell
Remove-Item -Recurse -Force build; powershell -ExecutionPolicy Bypass -File examples/win-dictation/build.ps1
```

## ✅ Success Indicators

You'll see during build:
```
[1/6] Detecting GPU capabilities...
  [OK] NVIDIA GPU detected: NVIDIA GeForce RTX 3090
  [OK] CUDA 13.0 toolkit - EXCELLENT!
  [OK] Full GPU acceleration enabled

[3/6] Configuring CMake...
  Enabling CUDA backend...
-- CUDA Toolkit found
-- Using CUDA architectures: native

[5/6] Deploying dependencies...
  [OK] Copied cudart64_130.dll
  [OK] Copied cublas64_13.dll
```

## 🎯 Test It

```powershell
.\build\bin\Release\win-dictation.exe
```

Check status bar should show:
```
⬤ Recording • GPU: ON • Buffer: X% • Threads: 24
```

**GPU: ON** = Success! 🎉

## 📊 Expected Performance Boost

| Metric | CPU-Only | GPU (RTX 3090) | Improvement |
|--------|----------|----------------|-------------|
| **Latency** | 2-3 sec | <1 sec | **3x faster** |
| **CPU Usage** | 60-80% | <10% | **8x lower** |
| **Throughput** | 5x realtime | >20x realtime | **4x faster** |

## ⚠️ Troubleshooting

### Build still shows "CPU-only"

**Check CUDA path:**
```powershell
$env:CUDA_PATH
```

**If it shows v11.7 or nothing:**
1. Completely close terminal
2. Reopen new terminal
3. Check again - should show v13.0

**If still wrong, manually set:**
```powershell
$env:CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0"
Remove-Item -Recurse -Force build
powershell -ExecutionPolicy Bypass -File examples/win-dictation/build.ps1
```

### App shows "GPU: OFF" even after GPU build

**Verify CUDA runtime:**
```powershell
ls .\build\bin\Release\cudart64_*.dll
```

Should exist. If not:
```powershell
Copy-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\cudart64_*.dll" .\build\bin\Release\
Copy-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\cublas64_*.dll" .\build\bin\Release\
Copy-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\cublasLt64_*.dll" .\build\bin\Release\
```

Then restart the app.

### Build fails with CUDA errors

1. Make sure Visual Studio 2022 is installed
2. Make sure CUDA 13.0 selected VS integration during install
3. Try rebuilding from VS Developer Command Prompt

## 🔄 Fallback to CPU

If GPU build fails, the CPU-only version still works great:
- Uses all 24 CPU threads
- ~5x real-time throughput
- ~2-3 second latency

The current build in `build/bin/Release/` is already optimized for CPU.

---

**Next:** See [CUDA-SETUP.md](CUDA-SETUP.md) for detailed troubleshooting.








