windows如何查看GPU显存被什么软件占用

Создано: 13 августа 2025 г.

Отвечено с использованием GPT-5 от Chat01

Вопрос

windows如何查看GPU显存被什么软件占用

Ответ

在 Windows 下查看 GPU 显存被哪些软件占用,可以用以下几种方法:


方法 1:任务管理器

  1. 快捷键 Ctrl + Shift + Esc 打开 任务管理器
  2. 切换到 “进程” 标签页。
  3. 在列标题上右键 → 选择 “GPU”“GPU 内存” 列。
  4. 现在你就可以看到每个进程的 GPU 占用率和显存使用量了。
    • 如果看不到这些列,确认你的 Windows 版本在 Win10 1709 及以上

方法 2:Windows 资源监视器(高级)

  1. Win + R → 输入 resmon → 回车。
  2. 资源监视器本身不能直接看 GPU 内存,但你可以用它配合任务管理器,定位高 GPU 占用的进程,然后再用专业工具分析。

方法 3:专业 GPU 监控工具

  • NVIDIA 用户

    • 打开 NVIDIA 控制面板 → “系统信息” → “显示进程”。
    • 或使用 nvidia-smi(需安装 NVIDIA 驱动或 CUDA 工具包):
      powershell
      nvidia-smi
      会显示每个进程的显存占用和 PID。
      配合任务管理器用 PID 找出对应软件。
  • AMD 用户

    • AMD Radeon Software(驱动自带) → “性能” → “进程”,查看显存使用情况。

方法 4:第三方监控工具

  • GPU-Z(免费轻量)
    可以实时监控 GPU 显存、频率、温度,但需要结合任务管理器判断进程。
  • MSI Afterburner / RivaTuner
    可以在屏幕上叠加显示显存使用情况,并记录日志。
  • Process Explorer(Sysinternals)
    可以替代任务管理器,查看更详细的进程 GPU 占用情况。

推荐做法
如果只是快速查看 → 用 任务管理器 就够了。
如果要找显存“吃”得多的后台程序 → 用 nvidia-smi / Radeon Software 更准确。


如果你愿意,我可以帮你写一个 Windows PowerShell 脚本,一键列出所有进程的显存占用情况,比任务管理器更详细。
你要我帮你写这个脚本吗?这样可以直接运行查看。

Вопрос

|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 4070 ... WDDM | 00000000:01:00.0 On | N/A |
| N/A 65C P4 10W / 130W | 6306MiB / 8188MiB | 6% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 2508 C+G ...xyewy\ShellExperienceHost.exe N/A |
| 0 N/A N/A 4224 C+G C:\Windows\explorer.exe N/A |
| 0 N/A N/A 13064 C+G ...easel-0.17.4\WeaselServer.exe N/A |
| 0 N/A N/A 14796 C+G ...Telegram Desktop\Telegram.exe N/A |
| 0 N/A N/A 14880 C+G ...ef.win7x64\steamwebhelper.exe N/A |看不到,为什么有6G占用

Ответ

你在 nvidia-smi 输出里看到 6GB 显存被占用,但进程列表全是 N/A,这是因为你当前的驱动是 WDDM 模式(Windows Display Driver Model),在这个模式下 nvidia-smi 无法显示大部分桌面图形进程的显存占用,只能在 TCC 模式 或 Linux 下看到完整信息。

在 WDDM 下,有几个原因会导致这种情况:


为什么有显存占用但进程显示 N/A

  1. 显卡用作桌面渲染
    Windows 桌面、动画、字体渲染、壁纸等会占用一部分显存,但这些进程(如 dwm.exe)在 nvidia-smi 下经常显示不出来。

  2. 视频缓冲与纹理缓存
    浏览器、视频播放、甚至任务栏小部件都会缓存纹理到显存。

  3. 显卡驱动与系统保留显存
    NVIDIA 驱动和 Windows 会预留一部分显存用于图形系统,不会列在进程列表里。

  4. 后台应用 / 隐藏进程
    有些应用使用 GPU 做加速,但不会被 nvidia-smi 在 WDDM 模式下列出来(比如某些 UWP 应用、硬件加速的后台服务)。


怎么查具体是哪些软件占用显存

由于 nvidia-smi 在 WDDM 模式下信息不全,可以换其他方法:

  1. 任务管理器

    • Ctrl + Shift + Esc → “进程”标签 → 在表头右键 → 勾选“GPU 内存”列
    • 按 GPU 内存排序,可以看到哪些进程占用最多
  2. Process Explorer(Sysinternals 工具)

  3. NVIDIA 控制面板 / GeForce Experience
    部分版本在“系统信息”里可以显示显存使用进程

  4. 第三方工具

    • GPU-Z:轻量显示显存情况
    • MSI Afterburner + RivaTuner:可以叠加显示显存占用并记录日志

如果你愿意,我可以帮你做一个 PowerShell 脚本,它会用 WMI 查询所有进程的 GPU 显存占用,比 nvidia-smi 在 WDDM 下更全,适合定位“吃显存”的后台程序。
这样你就能知道那 6GB 里具体是哪些软件占的。

你要我帮你写这个脚本吗?这样运行一次就能列出来。

Вопрос

Мысль

Crafting PowerShell Script

I'll provide a PowerShell script that enumerates per-process GPU memory usage on Windows. The idea is to leverage performance counters like \GPU Process(*)\Dedicated Usage and \GPU Adapter Memory(*)\Dedicated Usage. I'll also check for NVIDIA tools like nvidia-smi if available, and map processes to their full paths with additional error handling.

Writing PowerShell Script

I’ll write a PowerShell script to collect GPU memory usage stats. The values from counters are likely in bytes, so I’ll need to convert them to megabytes. For grouping by PID, I’ll use two counters for dedicated and shared usage. If using multiple GPUs, I’ll add those details for clarity too. I’ll also incorporate memory limits for a fuller picture.

Thought for 15s

Ответ

好嘞!下面是一份在 Windows 10/11(WDDM 模式) 下可用的 PowerShell 脚本,直接按进程统计 显存占用(Dedicated/Shared),弥补 nvidia-smi 在 WDDM 下显示 N/A 的问题。

用法

  1. 复制保存为 Get-GpuVramUsage.ps1
  2. 右键 以管理员身份 打开 PowerShell(非必须,但建议)
  3. 运行:
    powershell
    powershell -ExecutionPolicy Bypass -File .\Get-GpuVramUsage.ps1
  4. 如果你想持续监控(每2秒刷新一次):
    powershell
    .\Get-GpuVramUsage.ps1 -Watch

脚本(支持单次输出 & 监控刷新)

powershell
param( [switch]$Watch, [int]$IntervalSeconds = 2, [int]$Top = 50 ) function Get-GpuCountersAvailable { try { $c = Get-Counter -ListSet 'GPU Process' -ErrorAction Stop return $true } catch { return $false } } function Get-GpuProcessVramOnce { # 需要的性能计数器(显存:专用/共享) $counters = @( '\GPU Process(*)\Dedicated Usage', '\GPU Process(*)\Shared Usage' ) try { $samples = (Get-Counter -Counter $counters -ErrorAction Stop).CounterSamples } catch { Write-Warning "未能获取 \GPU Process\* 性能计数器。请确认系统为 Win10/11 较新版本并安装了 WDDM 驱动。" return @() } # 组装:PID -> {Name, DedicatedBytes, SharedBytes} $byPid = @{} foreach ($s in $samples) { # CounterPath 形如: \\MACHINE\gpu process(processname (1234))\dedicated usage $instance = $s.InstanceName if (-not $instance -or $instance -eq "_Total") { continue } if ($instance -match '$(\d+)$$') { $pid = [int]$matches[1] } else { continue } if (-not $byPid.ContainsKey($pid)) { $byPid[$pid] = [ordered]@{ PID = $pid Name = $null DedicatedBytes = 0 SharedBytes = 0 Path = $null } } $entry = $byPid[$pid] # 名称先用实例名前半段兜底,后面再用 Get-Process 修正 if (-not $entry.Name) { $namePart = $instance -replace '\s*$\d+$$','' $entry.Name = $namePart } $value = [double]$s.CookedValue if ($s.Path -match '\\Dedicated Usage$') { $entry.DedicatedBytes = [math]::Max($entry.DedicatedBytes, $value) } elseif ($s.Path -match '\\Shared Usage$') { $entry.SharedBytes = [math]::Max($entry.SharedBytes, $value) } } # 用 Get-Process 丰富进程信息(进程路径、友好名等) foreach ($pid in $byPid.Keys) { try { $p = Get-Process -Id $pid -ErrorAction Stop if ($p) { if ($p.Path) { $byPid[$pid].Path = $p.Path } # 用真实进程名覆盖 if ($p.ProcessName) { $byPid[$pid].Name = $p.ProcessName } } } catch {} } # 转为对象并换算单位 $rows = foreach ($kv in $byPid.GetEnumerator()) { $o = $kv.Value [pscustomobject]@{ Name = $o.Name PID = $o.PID 'GPU_DedicatedMB' = [math]::Round($o.DedicatedBytes / 1MB, 1) 'GPU_SharedMB' = [math]::Round($o.SharedBytes / 1MB, 1) Path = $o.Path } } # 排序,过滤掉全 0 的行 $rows | Where-Object { $_.GPU_DedicatedMB -gt 0 -or $_.GPU_SharedMB -gt 0 } | Sort-Object -Property GPU_DedicatedMB -Descending } function Get-AdapterVramSummary { # 适配器级显存使用/上限(可选,用于总览) $sum = $null try { $a = Get-Counter '\GPU Adapter Memory(*)\Dedicated Usage','\GPU Adapter Memory(*)\Dedicated Limit' -ErrorAction Stop $usage = @{} $limit = @{} foreach ($s in $a.CounterSamples) { if ($s.Path -match '\\Dedicated Usage$') { $usage[$s.InstanceName] = [double]$s.CookedValue } elseif ($s.Path -match '\\Dedicated Limit$') { $limit[$s.InstanceName] = [double]$s.CookedValue } } $sum = foreach ($k in $usage.Keys) { [pscustomobject]@{ Adapter = $k DedicatedUsedMB = [math]::Round($usage[$k]/1MB,1) DedicatedLimitMB = if ($limit.ContainsKey($k)) { [math]::Round($limit[$k]/1MB,1) } else { $null } } } } catch {} return $sum } if (-not (Get-GpuCountersAvailable)) { Write-Warning "未检测到 'GPU Process' 性能计数器。你的系统可能过旧或缺少图形驱动性能计数器。" Write-Host "可选替代:" Write-Host " 1) 任务管理器 -> 进程 -> 右键表头 -> 勾选“GPU 内存”" Write-Host " 2) Sysinternals Process Explorer -> View -> Select Columns -> GPU -> 勾选 GPU Memory" Write-Host " 3) NVIDIA 用户可配合 nvidia-smi(WDDM 限制下仍可能 N/A)" exit 1 } if ($Watch) { while ($true) { Clear-Host $sum = Get-AdapterVramSummary if ($sum) { Write-Host "=== 适配器显存总览(Dedicated) ===" $sum | Format-Table -AutoSize Write-Host "" } $rows = Get-GpuProcessVramOnce if (-not $rows -or $rows.Count -eq 0) { Write-Host "当前未检测到进程显存占用(或计数器无数据)。" } else { $rows | Select-Object -First $Top | Format-Table -AutoSize } Write-Host "" Write-Host ("提示:按 Ctrl+C 结束。下一次刷新:{0}s" -f $IntervalSeconds) Start-Sleep -Seconds $IntervalSeconds } } else { $sum = Get-AdapterVramSummary if ($sum) { Write-Host "=== 适配器显存总览(Dedicated) ===" $sum | Format-Table -AutoSize Write-Host "" } $rows = Get-GpuProcessVramOnce if (-not $rows -or $rows.Count -eq 0) { Write-Host "未检测到进程显存占用(或计数器暂无数据)。" } else { $rows | Select-Object -First $Top | Format-Table -AutoSize } }

说明与小贴士

  • 该脚本依赖 Windows 性能计数器\GPU Process(*)\Dedicated Usage / \GPU Process(*)\Shared Usage
    • 通常在 Windows 10 1709+ / Windows 11 + 新版显卡驱动下可用。
  • Dedicated 对应我们通常说的 显存(显卡专用内存)Shared 是与系统内存共享的部分。
  • 如果脚本提示没有 GPU Process 计数器:
    1. 更新到较新的 Windows 版本与显卡驱动;
    2. 退而求其次用 任务管理器Process Explorer 看每进程的 “GPU 内存”;
    3. NVIDIA 用户可同时参考 nvidia-smi总显存进程(但在 WDDM 下可能仍显示 N/A)。

需要我帮你把输出保存成 CSV/TSV(便于发我看)或者加上进程白名单/黑名单过滤也可以,我直接给你改好版本。

Вопрос

PS C:\Users\55821\Downloads\Compressed> powershell -ExecutionPolicy Bypass -File .\gpu.ps1

WARNING: 未检测到 'GPU Process' 性能计数器。你的系统可能过旧或缺少图形驱动性能计数器。
可选替代:

  1. 任务管理器 -> 进程 -> 右键表头 -> 勾选 GPU 内存
  2. Sysinternals Process Explorer -> View -> Select Columns -> GPU -> 勾选 GPU Memory
  3. NVIDIA 用户可配合 nvidia-smi(WDDM 限制下仍可能 N/A),上网搜索

Мысль

Exploring alternatives for GPU process tracking

It seems the system lacks GPU Process counters, so we need alternatives like ETW with Windows Performance Recorder and DirectX diagnostic tools. There's also WMI classes related to GPU performance, but if they're missing, we could use Process Explorer or command-line tools like nvidia-smi or DXGI to gather performance data.

Exploring options for GPU usage tracking

NVIDIA’s nvidia-smi command can show GPU memory used, but it's not perfect, and the Process Explorer method works best. I could suggest installing newer versions of Windows and NVIDIA drivers, but it might be easier to recommend Process Explorer, which is more reliable. There’s also the open-source ProcessHacker tool.

Exploring methods for tracking GPU memory use

I can guide the user through using Process Explorer to track GPU memory, though I can't provide a screenshot. For more advanced users, I can suggest installing the Windows Performance Toolkit to capture GPU memory allocations with specific commands. I'll include clear steps for both methods and also recommend updating Windows and drivers.

Alternative options: Process Explorer and GPU tracking

I can recommend using Process Explorer with columns like "GPU Usage" and "GPU Private Bytes" to monitor GPU usage. I'll provide instructions for enabling GPU counters, including updating drivers and installing the "Graphics Tools" feature for access to tools like GPUView and DX tools. We can also adjust scripts if necessary.

Thought for 30s

Ответ

明白了:你的系统里 “GPU Process” 性能计数器不可用,所以我那份脚本没法拿到“每进程显存(Dedicated/Shared)”。这在某些 Win10/Win11 版本 + 显卡驱动组合上会发生(尤其是独显直连/老驱动/企业镜像)。下面给你三个可行方案:


方案 A(最快):用 Process Explorer 精确看“每进程显存”

  1. 下载微软官方 Process Explorer(绿色版)
  2. 打开 → 菜单 View → Select Columns… → GPU
  3. 勾选:GPU Usage、GPU Dedicated Bytes、GPU Shared Bytes(至少勾“Dedicated Bytes”)
  4. 回到主界面,点列头“GPU Dedicated Bytes”排序,就能看到哪个进程吞了显存(等价于你在 nvidia-smi 看到的那 6GB 里是谁占的)。

小提示:dwm.exe、浏览器、播放器、Steam/游戏启动器、某些 IM(Telegram/Discord)都可能长期占显存;把每个进程关掉/重开即可验证释放情况。


方案 B(精准溯源):WPR/WPA 抓 GPU 显存 ETW(专业但非常准)

  1. 安装 Windows Performance Toolkit(WPR/WPA)(在“Windows ADK”里,勾选 Windows Performance Toolkit 即可)。
  2. 以管理员 PowerShell 执行:
    powershell
    wpr -cancel 2>$null wpr -start GPU -filemode # 复现“显存被吃”的场景 10~30 秒 wpr -stop "%USERPROFILE%\Desktop\gpu_trace.etl"
  3. Windows Performance Analyzer (WPA) 打开 gpu_trace.etl
    • 视图里添加 GPU Memory / GPU Queue 等表
    • GPU Memory 表中按 Process 分组,就能看到每个进程的显存分配峰值与时间线(最权威)。

方案 C(折中):我给你一份“无 GPU Process 计数器也能用”的脚本

这个脚本做两件事:

  • \GPU Adapter Memory\Dedicated Usage/Limit 给你总显存占用(印证 nvidia-smi 的 6GB)。
  • \GPU Engine(*)\Utilization Percentage 找到当下最可能的元凶进程(哪怕拿不到显存数,也能锁定对象),再去任务管理器/Process Explorer 里核对该进程的显存。

运行方法:保存为 GpuWhoUses.ps1,在 PowerShell 里执行
powershell -ExecutionPolicy Bypass -File .\GpuWhoUses.ps1 -Top 15 -Watch(每2秒刷新)

powershell
param( [switch]$Watch, [int]$IntervalSeconds = 2, [int]$Top = 20 ) function Get-AdapterVramSummary { try { $c = Get-Counter '\GPU Adapter Memory(*)\Dedicated Usage','\GPU Adapter Memory(*)\Dedicated Limit' -ErrorAction Stop } catch { return $null } $usage = @{} $limit = @{} foreach ($s in $c.CounterSamples) { if ($s.Path -match '\\Dedicated Usage$') { $usage[$s.InstanceName] = [double]$s.CookedValue } elseif ($s.Path -match '\\Dedicated Limit$') { $limit[$s.InstanceName] = [double]$s.CookedValue } } foreach ($k in $usage.Keys) { [pscustomobject]@{ Adapter = $k DedicatedUsedMB = [math]::Round($usage[$k]/1MB,1) DedicatedLimitMB = if ($limit.ContainsKey($k)) { [math]::Round($limit[$k]/1MB,1) } else { $null } } } } function Get-TopGpuUsersByEngine { # 用 GPU Engine 利用率定位“嫌疑进程”(没有 GPU Process 计数器时的退路) $engineCounters = '\GPU Engine(*)\Utilization Percentage' try { $samples = (Get-Counter -Counter $engineCounters -ErrorAction Stop).CounterSamples } catch { Write-Warning "无法读取 \GPU Engine\* 计数器。" return @() } $agg = @{} foreach ($s in $samples) { $inst = $s.InstanceName if (-not $inst -or $inst -eq "_Total") { continue } # 实例名通常形如:engtype_3D (pid_12345) / engtype_VideoDecode_0 (pid_6789) if ($inst -match 'pid[_\s]?(\d+)') { $pid = [int]$matches[1] if (-not $agg.ContainsKey($pid)) { $agg[$pid] = 0.0 } $agg[$pid] += [double]$s.CookedValue } } $rows = foreach ($pid in $agg.Keys) { $name = "(exited)" $path = $null try { $p = Get-Process -Id $pid -ErrorAction Stop $name = $p.ProcessName $path = $p.Path } catch {} [pscustomobject]@{ PID = $pid Name = $name GPU_Util_SumPct = [math]::Round($agg[$pid],1) # 各引擎利用率求和 Path = $path } } $rows | Sort-Object GPU_Util_SumPct -Descending } function RenderOnce($top) { $sum = Get-AdapterVramSummary if ($sum) { Write-Host "=== 适配器显存总览(Dedicated) ===" $sum | Format-Table -AutoSize Write-Host "" } else { Write-Host "未能读取适配器显存总览(可能计数器缺失)。" } $suspects = Get-TopGpuUsersByEngine if ($suspects.Count -gt 0) { Write-Host "=== 当前最可能的显存占用进程(按 GPU 引擎利用率排序) ===" $suspects | Select-Object -First $top | Format-Table -AutoSize Write-Host "" Write-Host "提示:将上面排前的进程在“任务管理器/Process Explorer”里查看列:GPU 内存(Dedicated),能直接看到它具体占了多少显存。" } else { Write-Host "当前未检测到明显的 GPU 引擎活动。若仍有高显存占用,可能是后台缓存/驱动保留或应用挂起但占显存。" } } if ($Watch) { while ($true) { Clear-Host RenderOnce -top $Top Write-Host ("按 Ctrl+C 结束。{0}s 后刷新…" -f $IntervalSeconds) Start-Sleep -Seconds $IntervalSeconds } } else { RenderOnce -top $Top }

建议你再做两步(可能让原脚本恢复可用)

  1. 更新显卡驱动(NVIDIA Studio/Game Ready 都行,尽量 2023/2024 年后的版本)。
  2. 升级 Windows 到较新版本(Win11 22H2+ 最稳),并在“可选功能”里安装 Graphics Tools(有时能带来/修复图形相关计数器)。

该怎么判断“6GB 到底是不是异常”?

  • 正常场景:打开多标签浏览器 + 4K/高刷桌面 + 视频播放/聊天软件 + Steam/游戏启动器 → 1~3GB 很常见;部分浏览器/解码器/桌面特效会往上冲。
  • 可疑场景:空桌面啥都没开,仍长期 >4~6GB;或关闭/退出应用后显存不降。这时多半是某个常驻进程(浏览器、UWP、播放器、显卡叠加、悬浮窗、屏幕投影/录制)在占。
    • Process Explorer 一眼能看出来;
    • 或用上面的 WPR/WPA 抓 30 秒,GPU Memory 表会非常直观地告诉你是哪个进程/时刻分配的。

如果你愿意,我也可以把 Process Explorer 的下载链接WPA 打开视图的具体菜单路径,以及 “一键导出 CSV” 的脚本再补上;或者你把 GpuWhoUses.ps1 的输出/截图发我,我帮你一起定位“6GB”是被谁吃掉的。

Поделиться этим Q&A