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

Aberta Para iniciantes
#3,468 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
80/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
api

Direção de pesquisa

Comece em cuda_core/cuda/core/system/_process.pxi linhas 21-26, onde used_gpu_memory é lido do NVML e retornado sem alterações. Leia a docstring de campo de cuda.bindings.nvml para NVML_VALUE_NOT_AVAILABLE, depois compare como gpu_instance_id lança NotSupportedError no mesmo módulo. Concluído significa que o sentinel é traduzido para None ou NotSupportedError e um teste cobre o caminho WDDM/N-A.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Cython
Estrelas
3.4k
Forks
353
Merge médio
2d 3h
PRs com merge (30d)
163

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NVIDIA/cuda-python

Todas as issues de NVIDIA/cuda-python

Issues semelhantes

Mais issues de Backend & API Design

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.