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

Ouverte
#3,467 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
Une demi-journée
Accessibilité débutants
62/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
c, python
Domaine
api

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Cython
Étoiles
3.4k
Forks
353
Merge moyen
2 j 3 h
PR mergées (30 j)
163

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de NVIDIA/cuda-python

Toutes les issues de NVIDIA/cuda-python

Issues similaires

Plus d'issues Backend & API Design

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.