[BUG]: system.Device.bar1_memory_info.reserved raises AttributeError on None

Aberta
#3,467 1 comentário 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
3/5
Tempo estimado
Meio dia
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, python
Domínio
api

Direção de pesquisa

Start by reading cuda_core/cuda/core/system/_memory.pxi around lines 36-51, where MemoryInfo._memory_info and its reserved getter live, then look at BAR1MemoryInfo in the same file to see the shadowing slot. Reproduce with the snippet in the issue to confirm bar1.reserved raises while total/free/used work. The fix is one of the two options the reporter lists (drop the inheritance or override reserved with a clear error) plus removing the duplicate slot; done means the repro prints or raises a documented exception and existing memory-info tests still pass.

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

Descrição

triage
Is this a duplicate?
Type of Bug

Runtime Error

Component

cuda.core

Describe the bug

BAR1MemoryInfo subclasses MemoryInfo but declares its own cdef object _memory_info. The subclass methods use the new slot. The reserved property it inherits from MemoryInfo reads the base class's slot, which is never set. So Device.bar1_memory_info.reserved exists (it's in dir(), and isinstance(bar1, MemoryInfo) is true) but raises an internal AttributeError on None:

https://github.com/NVIDIA/cuda-python/blob/ba7dcd05e545b7bf8a1a8fdfb451b406c03459cb/cuda_core/cuda/core/system/_memory.pxi#L36-L51

Code that handles a MemoryInfo generically (for example, logging total/used/free/reserved for both memory_info and bar1_memory_info) crashes on the BAR1 object.

How to Reproduce
from cuda.core import system

dev = system.Device(index=0)
bar1 = dev.bar1_memory_info
print(type(bar1).__mro__)
print("total:", bar1.total, "free:", bar1.free, "used:", bar1.used)
print("reserved:", bar1.reserved)

Output:

(<class 'cuda.core.system._device.BAR1MemoryInfo'>, <class 'cuda.core.system._device.MemoryInfo'>, <class 'object'>)
total: 8589934592 free: 8589934592 used: 0
Traceback (most recent call last):
  File "repro.py", line 7, in <module>
    print("reserved:", bar1.reserved)
                       ^^^^^^^^^^^^^
  File "cuda/core/system/_memory.pxi", line 41, in cuda.core.system._device.MemoryInfo.reserved.__get__
AttributeError: 'NoneType' object has no attribute 'reserved'
Expected behavior

BAR1MemoryInfo shouldn't expose a reserved attribute that can only crash. nvmlBAR1Memory_t has no reserved field, so either BAR1MemoryInfo stops inheriting from MemoryInfo, or it overrides reserved with a clear NotSupportedError/AttributeError. Either way, the shadowed _memory_info slot should go.

Operating System

Linux container (python:3.12-slim) on Windows 11 / WSL2 with the NVIDIA container runtime. The bug is in the Cython class layout, so the OS shouldn't matter.

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

The file 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.