o
    i7                     @   s8   d Z ddlZddlZddlZdd Zdd Zdd ZdS )	z9
Check OS requirements for ONNX Runtime Python Bindings.
    Nc            	      C   sZ  d} d}t   }d}d}|dkr+|} t   }|dvr)td| d d S d S |dkrd	 t|d	d	d
 } t|ddd }| sZt|ddd
 } t|ddd
 }|  } | }d S |dkr|} t   }t|	dd dk rtd| d d S d S |dkrdd l
}|d}|d}|d d	 }d S td| d d S )N z/etc/os-releasez/etc/lsb-releasewindows)10Z11zUnsupported Windows version (z4). ONNX Runtime supports Windows 10 and above, only.linux                     darwin.r   zUnsupported macOS version (z-). ONNX Runtime supports macOS 11.0 or later.aixoslevelzutf-8zUnsupported platform (zG). ONNX Runtime supports Linux, macOS, AIX and Windows platforms, only.)platformsystemlowerreleasewarningswarn	linecachegetlineintsplit
subprocesscheck_outputdecode)	Z__my_distro__Z__my_distro_ver__Z__my_system__Z__OS_RELEASE_FILE__Z__LSB_RELEASE_FILE__r   Zreturned_outputZ__my_distro_ver__strZ__my_distro_ver r    a/home/kim/smarthome/.venv/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_validation.pycheck_distro_info   sL   




r"   c               
   C   s   d} d}d}z ddl m} ddl m}  zddl m} W n	 ty$   Y nw W n tyA } ztd t| W Y d }~nd }~ww | ||fS )Nr   r   )__version__)package_name)cuda_versionz8WARNING: failed to collect package name and version info)	build_and_package_infor#   r$   r%   ImportError	Exceptionr   r   print)r$   versionr%   er    r    r!   !get_package_name_and_version_infoG   s$   

r,   c                     s  d } d}z
ddl m} d}W n; ty   d}Y n1 tyI } z%zddlm} t||r.d}W n ty:   d}Y nw |s?|} W Y d }~nd }~ww t \ |r rzHzddlm	 W n tym   t
d d Y nw  fd	d
}ddlm} |d d}r|r|vr|  t
d t
d|  W n ty } zt
d t| W Y d }~nd }~ww | r| | fS )NFr   )	ORTModuleT)ORTModuleInitExceptionr   )cudart_versionzBWARNING: failed to get cudart_version from onnxruntime build info.c                      sD   t d  t d  t d   t d  d S )Nz1onnxruntime training package info: package_name: z0onnxruntime training package info: __version__: z1onnxruntime training package info: cuda_version: z(onnxruntime build info: cudart_version: )r   r   r    r%   r/   r$   r*   r    r!   print_build_package_info   s   z7check_training_module.<locals>.print_build_package_info)find_cudart_versions)	build_envZbuild_cuda_versionzJWARNING: failed to find cudart version that matches onnxruntime build infoz WARNING: found cudart versions: z=WARNING: failed to collect onnxruntime version and build info)Zonnxruntime.training.ortmoduler-   r'   r(   Z(onnxruntime.training.ortmodule._fallbackr.   
isinstancer,   r&   r/   r   r   Z/onnxruntime.capi.onnxruntime_collect_build_infor2   r)   )Zimport_ortmodule_exceptionZhas_ortmoduler-   r+   r.   r1   r2   Zlocal_cudart_versionsr    r0   r!   check_training_module\   sZ   



r5   )__doc__r   r   r   r"   r,   r5   r    r    r    r!   <module>   s   9