a
    dJ                  	   @   s  d dl Z d dlZd dlZd dlmZ d dlZddlmZ dZdd Z	zej
dkrejd	krejd
k rejd ZedZeD ]2Zejer|zee W q| ey   Y q|0 q|edZeje dZdd Z	W n eefy   Y n0 dd Zdd Zdd Ze  dS )    N)warn   )_get_extension_pathFc                   C   s   dS )NF r   r   r   ^/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/torchvision/extension.py_has_ops   s    r   nt      )r
   	   PATH;Z_CTc                   C   s   dS )NTr   r   r   r   r   r   '   s    c                   C   s   t  stdd S )Na  Couldn't load custom C++ ops. This can happen if your PyTorch and torchvision versions are incompatible, or if you had errors while compiling torchvision from source. For further information on the compatible versions, check https://github.com/pytorch/vision#installation for the compatibility matrix. Please check your PyTorch version with torch.__version__ and your torchvision version with torchvision.__version__ and verify if they are compatible, and if not please reinstall torchvision so that it matches your PyTorch install.)r   RuntimeErrorr   r   r   r   _assert_has_ops.   s    r   c               
   C   s   t sdS ddlm}  tjj }|dkr| durt|}t|dk r^t|d }t|d }nt|dd }t|d }| 	d}t|d }t|d	 }||ks||krt
d
| d| d| d| d	|S )z`
    Make sure that CUDA versions match between the pytorch install and torchvision install
    r   )cudaNi'     r
   .r   zkDetected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=z" and torchvision has CUDA Version=zE. Please reinstall the torchvision that matches your PyTorch install.)_HAS_OPSZtorch.versionr   torchopsZtorchvisionZ_cuda_versionstrintsplitr   )Ztorch_version_cuda_versionZ
tv_versionZtv_majorZtv_minorZ	t_versionZt_majorZt_minorr   r   r   _check_cuda_version;   s6    
r   c                 C   s\   t | }tjdkrLtjdk rLtjddd}t|drD||d d nt	d t
j| d S )	Nr   r	   zkernel32.dllT)use_last_errorLoadLibraryExWi   z)LoadLibraryExW is missing in kernel32.dll)r   osnamesysversion_infoctypesZWinDLLhasattrr   r   r   r   load_library)Zlib_namelib_pathZ	_kernel32r   r   r   _load_libraryY   s    
r'   )r#   r   r!   warningsr   r   Z_internally_replaced_utilsr   r   r   r    r"   environZenv_pathr   Zpath_arrpathexistsZadd_dll_directory	Exceptionr&   r   r%   ImportErrorOSErrorr   r   r'   r   r   r   r   <module>   s6   

