o
    ;Î®cy  ã                   @   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   st   d}| r
|d |  }z)t  |¡}t|j_t  t j¡g|j_t  ¡ }| t  |¡¡}|dkr0W d S W |j	S    Y d S )Nzlibcudart.soÚ.r   )
ÚctypesÚCDLLÚintÚcudaRuntimeGetVersionÚrestypeÚPOINTERÚc_intÚargtypesÚbyrefÚvalue)Úfind_cudart_versionÚcudart_lib_filenameÚcudartÚversionÚstatus© r   úV/tmp/pip-target-vg8gfxp4/lib/python/onnxruntime/capi/onnxruntime_collect_build_info.pyÚget_cudart_version   s   
ÿýz0find_cudart_versions.<locals>.get_cudart_versionc                    ó   h | ]}ˆ |ƒ’qS r   r   )Ú.0Úcudart_version©r   r   r   Ú	<setcomp>,   ó    z'find_cudart_versions.<locals>.<setcomp>c                 S   ó   g | ]}|r|‘qS r   r   ©r   Úverr   r   r   Ú
<listcomp>/   r   z(find_cudart_versions.<locals>.<listcomp>©N)ÚsysÚplatformÚ
startswithÚwarningsÚwarn)Ú	build_envÚbuild_cuda_versionÚcudart_possible_versionsÚcudart_found_versionsr   r   r   Úfind_cudart_versions
   s   	

r*   c                    sX   t j d¡st d¡ d h}| s| h d£¡ d
dd„‰ ‡ fdd„|D ƒ}dd	„ |D ƒS )Nr   z'find_cudnn_versions only works on Linux>   ú8.2ú7.3.0ú7.3.1ú7.4.1ú7.4.2ú7.5.0ú7.5.1ú7.6.0ú7.6.1ú7.6.2ú7.6.3ú7.6.4ú7.6.5ú8.0.1ú8.0.2ú8.0.3ú8.0.4ú8.0.5ú8.1.0ú8.1.1c                 S   s:   d}| r
|d |  }zt  |¡}| ¡ }|W S    Y d S )Nzlibcudnn.sor   )r   r   ÚcudnnGetCudartVersion)Úfind_cudnn_versionÚcudnn_lib_filenameÚcudnnÚcuda_verr   r   r   Ú get_cudnn_supported_cuda_versionT   s   
zLfind_cudnn_supported_cuda_versions.<locals>.get_cudnn_supported_cuda_versionc                    r   r   r   )r   Úcudnn_version©rD   r   r   r   d   r   z5find_cudnn_supported_cuda_versions.<locals>.<setcomp>c                 S   r   r   r   r   r   r   r   r   g   r   z6find_cudnn_supported_cuda_versions.<locals>.<listcomp>r    )r!   r"   r#   r$   r%   Úupdate)r&   Úcudnn_possible_versionsÚcuda_found_versionsr   rF   r   Ú"find_cudnn_supported_cuda_versions2   s   
ÿ
rJ   )FN)F)r   r!   r$   r*   rJ   r   r   r   r   Ú<module>   s
   
(