o
    Rh6                  
   @   s  d Z dZdZz>ddlmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ dZW n e yX Z! ze!ZW Y dZ![!ndZ![!ww ddl"m#Z# erceddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* zdd	l+m,Z, W n	 e-y   Y nw e#. \Z/Z0Z1e0re0Ze#2  d
e3fddZ4dd
e3de3dB fddZ5dde6de6de6fddZ7dd Z8dde6de6de6fddZ9dS )a  
ONNX Runtime is a performance-focused scoring engine for Open Neural Network Exchange (ONNX) models.
For more information on ONNX Runtime, please see `aka.ms/onnxruntime <https://aka.ms/onnxruntime/>`_
or the `Github project <https://github.com/microsoft/onnxruntime/>`_.
z1.22.0	Microsoft    )ExecutionModeExecutionOrderGraphOptimizationLevelLoraAdapterModelMetadataNodeArgOrtAllocatorTypeOrtArenaCfgOrtMemoryInfo
OrtMemTypeOrtSparseFormat
RunOptionsSessionIOBindingSessionOptionscreate_and_register_allocator create_and_register_allocator_v2disable_telemetry_eventsenable_telemetry_eventsget_all_providersget_available_providersget_build_info
get_deviceget_version_stringhas_collective_opsset_default_logger_severityset_default_logger_verbosityset_seedN)onnxruntime_validation)AdapterFormatInferenceSession	IOBinding	OrtDeviceOrtValueSparseTensor   )experimentalpackage_namec                 C   s8   ddl m}m} z|| }W |S  |y   d }Y |S w )Nr   )PackageNotFoundErrorversion)importlib.metadatar(   r)   )r'   r(   r)   package_version r,   V/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/onnxruntime/__init__.py_get_package_versionW   s   
r.   directory_namec                 C   s   ddl m}m} |p| }z<|| }|jpg }|D ]}|jdr-||jv r-| j  W S q|sC|D ]}|jdrB| j  W S q2W d S W d S  |yR   Y d S w )Nr   )r(   distributionz__init__.py)	r*   r(   r0   filesnameendswithpartslocateparent)r'   r/   r(   r0   root_directory_namedistr1   filer,   r,   r-   _get_package_roota   s,   
r:   T
is_windowscudacudnnc                 C   s>   | rg d}g d}ng d}dg}|r|ng |r| S g  S )N))nvidiacublasbinzcublasLt64_12.dll)r>   r?   r@   zcublas64_12.dll)r>   cufftr@   zcufft64_11.dll)r>   cuda_runtimer@   zcudart64_12.dll))r>   r=   r@   z&cudnn_engines_runtime_compiled64_9.dll)r>   r=   r@   z!cudnn_engines_precompiled64_9.dll)r>   r=   r@   zcudnn_heuristic64_9.dll)r>   r=   r@   zcudnn_ops64_9.dll)r>   r=   r@   zcudnn_adv64_9.dll)r>   r=   r@   zcudnn_graph64_9.dll)r>   r=   r@   zcudnn64_9.dll))r>   r?   libzlibcublasLt.so.12)r>   r?   rC   zlibcublas.so.12)r>   
cuda_nvrtcrC   zlibnvrtc.so.12)r>   curandrC   zlibcurand.so.10)r>   rA   rC   zlibcufft.so.11)r>   rB   rC   zlibcudart.so.12)r>   r=   rC   zlibcudnn.so.9r,   )r;   r<   r=   cuda_dll_pathscudnn_dll_pathsr,   r,   r-   _get_nvidia_dll_pathsy   s   
rH   c               	   C   s<  ddl } ddl}ddl}ddlm} tt dt  tr$tdt  td|  td g }| D ]-}|j	d }|d	ksD|
d
rat|d	}|ra||vra|| t| d|j d|  q4t|dkrltd trg d}|D ](}|
dr}dnd}	t|}
|
rt| d|
 dt||	  qtt| d qt| dkrtd|jd   n| dkrtd|jd   | jdrdtfdd}ddl}|| }td | D ]}||j rt|j qtr| jdr| jdrdd lm} td! t|  dS td" dS dS td# dS )$z$Print information to help debugging.r   N)distributionsz
 version: zCUDA version used in build: z	platform:z&
Python package, version and location:Nameonnxruntime)zonnxruntime-zort-z==z at r%   z[33mWARNING: multiple onnxruntime packages are installed to the same location. Please 'pip uninstall` all above packages, then `pip install` only one of them.[0m)torchznvidia-cuda-runtime-cu12znvidia-cudnn-cu12znvidia-cublas-cu12znvidia-cufft-cu12znvidia-curand-cu12znvidia-cuda-nvrtc-cu12znvidia-nvjitlink-cu12znvidia-r>   z not installedWindowsz
Environment variable:
PATH=PATHLinuxz'
Environment variable:
LD_LIBRARY_PATH=LD_LIBRARY_PATHpsutilpathc                    s6   ddg}t rddddddg|}t fd	d
|D S )Nvcruntime140msvcp140rA   r?   cudartnvrtcrE   r=   c                 3   s    | ]}| v V  qd S Nr,   ).0keywordrR   r,   r-   	<genexpr>   s    z:print_debug_info.<locals>.is_target_dll.<locals>.<genexpr>)cuda_versionany)rR   target_keywordsr,   rZ   r-   is_target_dll   s   z'print_debug_info.<locals>.is_target_dllz
List of loaded DLLs:cpuinfopy3nvml)get_device_infoz
Device information:zCplease `pip install py-cpuinfo py3nvml` to show device information.z0please `pip install psutil` to show loaded DLLs.)importlib.utilosplatformr*   rI   printr'   __version__r\   metadata
startswithr:   appendr)   lenr.   systemenvironutil	find_specstrrQ   Processgetpidmemory_mapsrR   lowertransformers.machine_inforb   )	importlibrd   re   rI   ort_packagesr8   packagelocationpackagesr/   r)   r_   rQ   prC   rb   r,   r,   r-   print_debug_info   sf   




 
	r|   msvcc                 C   s  ddl }ddl}ddl}ddl}| dvrdS | dk}|rK|rKz|d |d | dkr8|d W n tyJ   td	 td
 Y nw t	rRt	
ds`| sV|r`tdt d dS t	rkt	
drk| sm|smdS d}	|rtd}
|
ozd|
v }d|jv r|}	|
rd|
v r|std|
 dt d |r|du rtdd}|r|j|d}|pd}|j|s|j|jt|}|j|}|j|std| d|	rtd dS t|| |}g }|D ]J}|r|j||d n	|jj|g|R  }|j|r.z||}||d  W q ty- } ztd| d|  W Y d}~qd}~ww qd}|D ]5}|d }||vrgz||}W q3 tyf } zd}td| d|  W Y d}~q3d}~ww q3|rrtd dS dS )aE  Preload CUDA 12.x and cuDNN 9.x DLLs in Windows or Linux, and MSVC runtime DLLs in Windows.

       When the installed PyTorch is compatible (using same major version of CUDA and cuDNN),
       there is no need to call this function if `import torch` is done before `import onnxruntime`.

    Args:
        cuda (bool, optional): enable loading CUDA DLLs. Defaults to True.
        cudnn (bool, optional): enable loading cuDNN DLLs. Defaults to True.
        msvc (bool, optional): enable loading MSVC DLLs in Windows. Defaults to True.
        directory(str, optional): a directory contains CUDA or cuDNN DLLs. It can be an absolute path,
           or a path relative to the directory of this file.
           If directory is None (default value), the search order: the lib directory of compatible PyTorch in Windows,
            nvidia site packages, default DLL loading paths.
           If directory is empty string (""), the search order: nvidia site packages, default DLL loading paths.
           If directory is a path, the search order: the directory, default DLL loading paths.
    r   N)rM   rO   rM   zvcruntime140.dllzmsvcp140.dllARM64zvcruntime140_1.dllz]Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.zGIt can be downloaded at https://aka.ms/vs/17/release/vc_redist.x64.exe.z12.z[33mWARNING: z is not built with CUDA 12.x support. Please install a version that supports CUDA 12.x, or call preload_dlls with cuda=False and cudnn=False.[0mFrL   z+cu12z+cuz$[33mWARNING: The installed PyTorch zX does not support CUDA 12.x. Please install PyTorch for CUDA 12.x to be compatible with z.[0mrC   z..zInvalid parameter of directory=z. The directory does not exist!z9Skip loading CUDA and cuDNN DLLs since torch is imported.zFailed to load z: Tz\Please follow https://onnxruntime.ai/docs/install/#cuda-and-cudnn to install CUDA and CuDNN.)ctypesrd   re   sysrl   CDLLmachineOSErrorrf   r\   ri   r'   r.   modulesr:   rR   joinisabsdirname__file__normpathisdirRuntimeErrorrH   isfilerj   	Exception)r<   r=   r}   	directoryr   rd   re   r   r;   is_cuda_cudnn_imported_by_torchtorch_versionis_torch_for_cuda_12
torch_rootbase_directory	dll_pathsloaded_dllsrelative_pathdll_path_ehas_failuredll_filenamer,   r,   r-   preload_dlls   s   






 
"r   rW   )TT)TTTN):__doc__rg   
__author__onnxruntime.capi._pybind_stater   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   import_capi_exceptionr   r   onnxruntime.capir   1onnxruntime.capi.onnxruntime_inference_collectionr   r    r!   r"   r#   r$    r&   ImportError!get_package_name_and_version_infor'   r)   r\   check_distro_inforp   r.   r:   boolrH   r|   r   r,   r,   r,   r-   <module>   s8   t 

%S