
    PhQ                        U 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mZm	Z	 	 d dl
mZ daed Znd Zd Zej                   ej"                  ej$                  hZd Zd	 Z	 	 	 	 	 dd
Ze	 	 	 	 	 dd       Z G d de	      Z eej2                  e   e      ej2                  e<   eed<   eed<   eed<   eed<   eed<   y# e$ r dZY w xY w)    N)contextmanager)__allow_nonbracketed_mutationContextProp
PropModule)_cudnnc                  0  	 t         t        j                         a t        j                         } t        j                         }| \  }}}|\  }}}||k7  rd}n |dk  st        j
                  s||k(  }n||k\  }|st        j                  j                  dd      dk(  ryd| d|  d	}d
t        j                  v rRt        j                  j                  d
d      	t        	fddD              rt        | d|       t        | d      t        |      y)NF   &PYTORCH_SKIP_CUDNN_COMPATIBILITY_CHECK01Tz=cuDNN version incompatibility: PyTorch was compiled  against z but found runtime version z. PyTorch already comes bundled with cuDNN. One option to resolving this error is to ensure PyTorch can find the bundled cuDNN. LD_LIBRARY_PATH c              3   &   K   | ]  }|v  
 y wN ).0	substringld_library_paths     hC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\torch/backends/cudnn/__init__.py	<genexpr>z_init.<locals>.<genexpr>7   s      FW	_4FWs   )cudacudnnzLooks like your LD_LIBRARY_PATH contains incompatible version of cudnn. Please either remove it from the path or install cudnn zHone possibility is that there is a conflicting cuDNN in LD_LIBRARY_PATH.)__cudnn_versionr   getVersionIntgetRuntimeVersiongetCompileVersionis_cudaosenvirongetanyRuntimeError)
runtime_versioncompile_versionruntime_majorruntime_minor_compile_majorcompile_minorcudnn_compatiblebase_error_msgr   s
            @r   _initr,      sU   "$224O$668O$668O.=+M=!.=+M=! -#( "&..#0M#A #0M#A #::>>"JCPTWW55D4E F11@0A B34  %

2&(jjnn5F&KO FW  +-.VVeUfh  +-.DE  '~66    c                       y)NFr   r   r-   r   r,   r,   L   s    r-   c                  $    t               syt        S )zReturn the version of cuDNN.N)r,   r   r   r-   r   versionr0   P   s    7r-   c                  6    t         j                  j                  S )z9Return a bool indicating if CUDNN is currently available.)torch_C
_has_cudnnr   r-   r   is_availabler5   ^   s    88r-   c                 |   t         j                  j                         sy| j                  j                  dk7  s| j
                  t        vryt               st        j                  d       yt               sGt        j                  dj                  dddj                  t        j                  d      	             yy
)NFr   zPyTorch was compiled without cuDNN/MIOpen support. To use cuDNN/MIOpen, rebuild PyTorch making sure the library is visible to the build system.z4cuDNN/MIOpen library not found. Check your {libpath}DYLD_LIBRARY_PATHPATH)darwinwin32r   )libpathT)r2   r3   _get_cudnn_enableddevicetypedtypeCUDNN_TENSOR_DTYPESr5   warningswarnr,   formatr    sysplatform)tensors    r   is_acceptablerG   c   s    88&&(}}V#v||;N'N>N	
 7BII#6HLLLL"3 J 	
 r-   c                    t         j                  j                         t         j                  j                         t	               sd nt         j                  j                         t         j                  j                         t         j                  j                         f}| t         j                  j                  |        |t         j                  j                  |       |)t	               rt         j                  j                  |       |t         j                  j                  |       |t         j                  j                  |       |S r   )r2   r3   r<   _get_cudnn_benchmarkr5   _cuda_get_cudnn_benchmark_limit_get_cudnn_deterministic_get_cudnn_allow_tf32_set_cudnn_enabled_set_cudnn_benchmark_cuda_set_cudnn_benchmark_limit_set_cudnn_deterministic_set_cudnn_allow_tf32)_enabled
_benchmark_benchmark_limit_deterministic_allow_tf32
orig_flagss         r   	set_flagsrX   z   s     	##%%%' N(P(P(R))+&&(J ##H-%%j1#001AB!)).9&&{3r-   c              #     K   t               5  t        | ||||      }d d d        	 d  t               5  t          d d d        y # 1 sw Y   *xY w# 1 sw Y   y xY w# t               5  t          d d d        w # 1 sw Y   w xY wxY wwr   )r   rX   )enabled	benchmarkbenchmark_limitdeterministic
allow_tf32rW   s         r   flagsr_      ss      
'	(Y


 
)# +,z" -, 
)	( -,*,z" -,,s_   B
AB
A 
B
	A	B
AB
AB
B)	A;2	B;B BB
c                       e Zd Z fdZ eej                  j                  ej                  j                        Z	 eej                  j                  ej                  j                        Z eej                  j                  ej                  j                        ZdZ e       r1 eej                  j$                  ej                  j&                        Z eej                  j(                  ej                  j*                        Z xZS )CudnnModulec                 &    t         |   ||       y r   )super__init__)selfmname	__class__s      r   rd   zCudnnModule.__init__   s    D!r-   N)__name__
__module____qualname__rd   r   r2   r3   r<   rM   rZ   rK   rP   r]   rI   rN   r[   r\   r5   rJ   rO   rL   rQ   r^   __classcell__)rh   s   @r   ra   ra      s    " %((55uxx7R7RSG))588+L+LM %%uxx'D'DI O~%HH44HH44
 &&(F(FJr-   ra   rZ   r]   r[   r^   r\   )NNNNN)FF
   FT)r   rD   rA   
contextlibr   r2   torch.backendsr   r   r   torch._Cr   ImportErrorr   r,   r0   halffloatdoubler@   r5   rG   rX   r_   ra   modulesri   bool__annotations__intr   r-   r   <module>ry      s   	 
  %  Q Q 	0h 
JJ	KK	LL 
0 6 # #0* 0 $CKK$98DH  
   E  Fs   B? ?C	C	