o
    i	                     @   s\   d dl mZ d dlmZ d dlZd dlmZ edd Zededej	e
B dB fd	d
ZdS )    )contextmanager)cacheN)nvmlc                	   C   sV   t   z!zt   W n t jt jfy   Y W t   dS w W t   dS t   w )z
    Tries to call the simplest NVML API possible to see if just the basics
    works.  If not we are probably on one of the platforms where NVML is not
    supported at all (e.g. Jetson Orin).
    FT)r   init_v2system_get_driver_branchNotSupportedErrorUnknownErrorshutdown r
   r
   Z/home/ubuntu/.local/lib/python3.10/site-packages/cuda/bindings/_test_helpers/arch_check.pyhardware_supports_nvml   s   r   deviceexpected_device_archc                 c   s   t | }t|t jrt|}n	|dkrd}nd}|d u s(|dks(|t jjkrMzd V  W d S  t jyL   tdt |j	 dt 
|  d Y d S w t||k r}tt j d V  W d    n1 sgw   Y  td|j	 d	t 
|   d S d V  d S )
NFERMI   r   HAS_INFOROMz)Unsupported call for device architecture z on device ''zUnsupported before z, got )r   device_get_architecture
isinstance
DeviceArchintUNKNOWNr   pytestskipnamedevice_get_nameraises)r   r   device_archexpected_device_arch_intr
   r
   r   unsupported_before   s.   


"
r   )
contextlibr   	functoolsr   r   cuda.bindingsr   r   r   r   strr   r
   r
   r
   r   <module>   s   
"