U
    “±Ëh}  ã                   @   s0   d dl Z d dlZd dlZddd„Zddd„ZdS )	é    NFc                    sL   t j d¡st d¡ d S d |h}d	dd„‰ ‡ fdd„|D ƒ}dd„ |D ƒS )
NÚlinuxz(find_cudart_versions only works on Linuxc                 S   s€   d}| r|d |  }zNt  |¡}t|j_t  t j¡g|j_t  ¡ }| t  |¡¡}|dkr`W d S W n t	k
rx   Y d S X |j
S )Nzlibcudart.soÚ.r   )ÚctypesÚCDLLÚintZcudaRuntimeGetVersionÚrestypeÚPOINTERÚc_intÚargtypesÚbyrefÚ	ExceptionÚvalue)Zfind_cudart_versionZcudart_lib_filenameZcudartÚversionÚstatus© r   úS/tmp/pip-unpacked-wheel-socb9apf/onnxruntime/capi/onnxruntime_collect_build_info.pyÚget_cudart_version   s    

z0find_cudart_versions.<locals>.get_cudart_versionc                    s   h | ]}ˆ |ƒ’qS r   r   )Ú.0Zcudart_version©r   r   r   Ú	<setcomp>,   s     z'find_cudart_versions.<locals>.<setcomp>c                 S   s   g | ]}|r|‘qS r   r   ©r   Úverr   r   r   Ú
<listcomp>/   s      z(find_cudart_versions.<locals>.<listcomp>)N)ÚsysÚplatformÚ
startswithÚwarningsÚwarn)Ú	build_envZbuild_cuda_versionZcudart_possible_versionsZcudart_found_versionsr   r   r   Úfind_cudart_versions
   s    	

r   c                    s|   t j d¡st d¡ d h}| sR| ddddddd	d
ddddddddddddh¡ ddd„‰ ‡ fdd„|D ƒ}dd„ |D ƒS )Nr   z'find_cudnn_versions only works on Linuxz8.2z8.1.1z8.1.0z8.0.5z8.0.4z8.0.3z8.0.2z8.0.1z7.6.5z7.6.4z7.6.3z7.6.2z7.6.1z7.6.0z7.5.1z7.5.0z7.4.2z7.4.1z7.3.1z7.3.0c                 S   sH   d}| r|d |  }zt  |¡}| ¡ }|W S  tk
rB   Y d S X d S )Nzlibcudnn.sor   )r   r   ZcudnnGetCudartVersionr   )Zfind_cudnn_versionZcudnn_lib_filenameZcudnnZcuda_verr   r   r   Ú get_cudnn_supported_cuda_versionT   s    
zLfind_cudnn_supported_cuda_versions.<locals>.get_cudnn_supported_cuda_versionc                    s   h | ]}ˆ |ƒ’qS r   r   )r   Zcudnn_version©r    r   r   r   d   s     z5find_cudnn_supported_cuda_versions.<locals>.<setcomp>c                 S   s   g | ]}|r|‘qS r   r   r   r   r   r   r   g   s      z6find_cudnn_supported_cuda_versions.<locals>.<listcomp>)N)r   r   r   r   r   Úupdate)r   Zcudnn_possible_versionsZcuda_found_versionsr   r!   r   Ú"find_cudnn_supported_cuda_versions2   s<    
ìÿ
r#   )FN)F)r   r   r   r   r#   r   r   r   r   Ú<module>   s   
(