Windows: VRAM 4GB 미만 NVIDIA GPU는 Ollama를 CPU로 실행

MX150(2GB)처럼 VRAM이 작은 NVIDIA GPU에서는 드라이버의 CUDA 버전이
Ollama보다 낮으면 'PTX was compiled with an unsupported toolchain' 오류로
모든 모델 실행이 실패함. 가속 이득도 거의 없으므로 사양 감지 단계에서
CPU로 판단하고, 서버 기동 시 CUDA_VISIBLE_DEVICES=-1 을 넘김.
기준값은 $MinGpuVramGB (기본 4GB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HnDmXvY8ekNA8cQwBmcsUE
This commit is contained in:
Claude
2026-10-28 21:30:00 +00:00
parent 9ae2c7cb7e
commit 8d570c890a

View File

@@ -100,6 +100,7 @@ $ComfyImageRepo = 'localhost/comfyui-cpu'
$ComfyGitUrl = 'https://github.com/Comfy-Org/ComfyUI'
$ComfyReleaseApi = 'https://api.github.com/repos/Comfy-Org/ComfyUI/releases?per_page=30'
$ComfyBasePort = 8188
$MinGpuVramGB = 4 # NVIDIA GPU의 VRAM이 이보다 작으면 Ollama를 CPU로 실행 (CUDA 오류 방지)
$ComfyBind = '0.0.0.0' # 내부망의 다른 PC도 접속 가능
$ComfyMinMemGB = 8 # 가상 머신 메모리가 이보다 적으면 크기 조정 제안
$StackNetwork = 'ollama-stack' # WebUI·ComfyUI가 서로 이름으로 접속하는 내부 네트워크
@@ -388,9 +389,19 @@ function Get-Hardware {
# Ollama가 가속에 쓸 수 있는 GPU 판단
$nvidia = @($gpus | Where-Object { $_.Vendor -eq 'NVIDIA' })
$amd = @($gpus | Where-Object { $_.Vendor -eq 'AMD' -and $_.VramGB -ge 4 })
if ($nvidia.Count -gt 0) {
$forceCpu = $false
$nvidiaVram = 0
if ($nvidia.Count -gt 0) { $nvidiaVram = [double](($nvidia | Measure-Object -Property VramGB -Sum).Sum) }
if ($nvidia.Count -gt 0 -and $nvidiaVram -lt $MinGpuVramGB) {
# 보급형·구형 NVIDIA (예: MX150 2GB): 이득은 거의 없고 드라이버가 Ollama의 CUDA 버전보다 오래되면
# 'PTX was compiled with an unsupported toolchain' 오류로 모델 실행이 실패하므로 CPU로 고정
$accel = 'CPU'
$usable = 0
$forceCpu = $true
$accelNote = "NVIDIA GPU의 VRAM이 ${nvidiaVram}GB로 ${MinGpuVramGB}GB 미만이라 GPU를 끄고 CPU로 실행합니다. (CUDA 오류 방지)"
} elseif ($nvidia.Count -gt 0) {
$accel = 'NVIDIA'
$usable = ($nvidia | Measure-Object -Property VramGB -Sum).Sum
$usable = $nvidiaVram
$accelNote = 'NVIDIA GPU(CUDA) 가속을 사용합니다.'
} elseif ($amd.Count -gt 0) {
$accel = 'AMD'
@@ -416,6 +427,7 @@ function Get-Hardware {
Gpus = $gpus
Accel = $accel
AccelNote = $accelNote
ForceCpu = $forceCpu
UsableVramGB = [double]$usable
MainGpu = $mainGpu
ModelsDir = (Get-ModelsDir)
@@ -1489,6 +1501,11 @@ function Invoke-ServerLaunch([int]$Ctx = 0) {
$env:OLLAMA_CONTEXT_LENGTH = "$Ctx"
$env:OLLAMA_FLASH_ATTENTION = "$($p.FlashAttention)"
$env:OLLAMA_KV_CACHE_TYPE = $p.KvCacheType
if ($script:HW -and $script:HW.ForceCpu) {
# GPU를 쓰지 않도록 CUDA 장치를 숨김 (VRAM이 작은 NVIDIA GPU에서 CUDA 오류 방지)
$env:CUDA_VISIBLE_DEVICES = '-1'
Write-C "${CYAN} GPU 끔: $($script:HW.AccelNote)${RESET}"
}
$proc = $null
try {