o
    3Ih                     @   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)10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)	__my_distro____my_distro_ver____my_system____OS_RELEASE_FILE____LSB_RELEASE_FILE__r   returned_output__my_distro_ver__str__my_distro_ver r)   g/home/air/sanwanet/gpt-api/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$   

r5   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.   r8   r-   r3   r)   r*   print_build_package_info   s   z7check_training_module.<locals>.print_build_package_info)find_cudart_versions)	build_env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)onnxruntime.training.ortmoduler6   r0   r1   (onnxruntime.training.ortmodule._fallbackr7   
isinstancer5   r/   r8   r   r   /onnxruntime.capi.onnxruntime_collect_build_infor;   r2   )import_ortmodule_exceptionhas_ortmoduler6   r4   r7   r:   r;   local_cudart_versionsr)   r9   r*   check_training_module\   sZ   



rE   )__doc__r   r   r   r+   r5   rE   r)   r)   r)   r*   <module>   s   9