[BUG]: ProcessInfo.used_gpu_memory returns the NVML_VALUE_NOT_AVAILABLE sentinel as a byte count

未關閉 適合新手
#3,468 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
80/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
api

研究方向

從 cuda_core/cuda/core/system/_process.pxi 第 21-26 行開始,其中 used_gpu_memory 會從 NVML 讀取並原樣傳回。閱讀 cuda.bindings.nvml 中針對 NVML_VALUE_NOT_AVAILABLE 的欄位 docstring,然後比較同一模組中 gpu_instance_id 如何拋出 NotSupportedError。完成代表要將該哨兵值轉換成 None 或 NotSupportedError,並且有一個測試涵蓋 WDDM/N-A 路徑。

由索引模型根據 Issue 內容生成。

描述

triage
Is this a duplicate?
Type of Bug

Silent Failure

Component

cuda.core

Describe the bug

ProcessInfo.used_gpu_memory is documented as "the amount of GPU memory (in bytes) used by the process", but it returns NVML's NVML_VALUE_NOT_AVAILABLE sentinel unchanged when the driver can't report it. Under WDDM, which includes WSL2, that is always the case. The caller gets 18446744073709551615 (2**64 - 1) and can't tell it apart from a real byte count. nvidia-smi shows [N/A] for the same process.

https://github.com/NVIDIA/cuda-python/blob/ba7dcd05e545b7bf8a1a8fdfb451b406c03459cb/cuda_core/cuda/core/system/_process.pxi#L21-L26

The cuda.bindings.nvml docstring for the underlying field does mention the sentinel ("Under WDDM, NVML_VALUE_NOT_AVAILABLE is always reported"). The cuda.core wrapper doesn't translate it or document it. Summing or comparing used_gpu_memory across processes gives nonsense values.

How to Reproduce

On a WDDM / WSL2 system:

import cuda.core
from cuda.core import system

cuda.core.Device(0).set_current()  # make this process a compute process
dev = system.Device(index=0)
for p in dev.compute_running_processes:
    print(p.pid, p.used_gpu_memory)

Output:

1397 18446744073709551615
1120 18446744073709551615

nvidia-smi --query-compute-apps=pid,used_memory --format=csv on the same machine:

pid, used_gpu_memory [MiB]
1120, [N/A]
Expected behavior

When NVML reports NVML_VALUE_NOT_AVAILABLE, used_gpu_memory should say so, for example by returning None or raising NotSupportedError (the way gpu_instance_id does for non-MIG devices). It shouldn't return the raw sentinel as a byte count.

Operating System

Linux container (python:3.12-slim) on Windows 11 / WSL2 with the NVIDIA container runtime.

nvidia-smi output
| NVIDIA-SMI 610.59                 KMD Version: 610.91        CUDA UMD Version: 13.3     |
|   0  NVIDIA GeForce RTX 3050 ...    On  |   00000000:01:00.0 Off |                  N/A |

Python 3.12.16. Packages:

cuda-bindings     13.5.0
cuda-core         1.3.0
cuda-pathfinder   1.9.0
cuda-toolkit      13.5.0
cupy-cuda13x      14.2.0
numpy             2.5.4
nvidia-cuda-nvrtc 13.5.37
nvidia-cufile     1.20.0.107
nvidia-nvfatbin   13.5.37
nvidia-nvjitlink  13.5.37
nvidia-nvvm       13.5.37

_process.pxi is unchanged between cuda-core-v1.3.0 and current main (ba7dcd0).

Happy to send a fix if that helps.

主要語言
Cython
星號
3.4k
分支
353
平均合併
2 天 3 小時
30 天內合併 PR
163

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NVIDIA/cuda-python 的其他 Issue

查看 NVIDIA/cuda-python 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。