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

Aperta Adatta ai principianti
#3,468 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api

Direzione di ricerca

Inizia da cuda_core/cuda/core/system/_process.pxi righe 21-26, dove used_gpu_memory viene letto da NVML e restituito invariato. Leggi la docstring del campo di cuda.bindings.nvml per NVML_VALUE_NOT_AVAILABLE, poi confronta come gpu_instance_id solleva NotSupportedError nello stesso modulo. Fatto significa che il sentinel viene tradotto in None o NotSupportedError e un test copre il percorso WDDM/N-A.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Cython
Stelle
3.4k
Fork
353
Merge medio
2g 3h
PR unite (30g)
163

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cuda-python

Tutte le issue di NVIDIA/cuda-python

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.