
    sh                        % S SK r S SKrS SKrS SKJr  S SKJr  S SKrS SKJ	r	J
r
Jr   S SKJr  Sq\\   \S'   \b  S rOS rS	 r\R(                  \R*                  \R,                  1rS
 rS r     SS jr\     SS j5       r " S S\5      r\" \R:                  \   \5      \R:                  \'   \\S'   \\S'   \\S'   \\S'   \\S'   g! \ a    Sr Nf = f)    N)contextmanager)Optional)__allow_nonbracketed_mutationContextProp
PropModule)_cudnn__cudnn_versionc                  X  ^	 [         Gc!  [        R                  " 5       q [        R                  " 5       n [        R                  " 5       nU u  p#nUu  pVnX%:w  a  SnO$US:  d  [        R
                  (       d  X6:H  nOX6:  nU(       d  [        R                  R                  SS5      S:X  a  gSU SU  S	3nS
[        R                  ;   aX  [        R                  R                  S
S5      m	[        U	4S jS 5       5      (       a  [        U SU 35      e[        U S35      e[        U5      eg)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   ,   >#    U  H	  oT;   v   M     g 7fN ).0	substringld_library_paths     q/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/torch/backends/cudnn/__init__.py	<genexpr>_init.<locals>.<genexpr>:   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.)r	   r   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.      sP   "$224O$668O$668O.=+M!.=+M! -#( "&..#0#A #0#A #::>>"JCPTWW55D4E F11@0A B34  %

2&(jjnn5F&KO FW   +-.VVeUfh  +-.DE  '~66    c                      g)NFr   r   r/   r   r.   r.   O   s    r/   c                  .    [        5       (       d  g[        $ )zReturn the version of cuDNN.N)r.   r	   r   r/   r   versionr2   S   s    77r/   c                  6    [         R                  R                  $ )z9Return a bool indicating if CUDNN is currently available.)torch_C
_has_cudnnr   r/   r   is_availabler7   a   s    88r/   c                    [         R                  R                  5       (       d  gU R                  R                  S:w  d  U R
                  [        ;  a  g[        5       (       d  [        R                  " S5        g[        5       (       dE  [        R                  " SR                  SSS.R                  [        R                  S5      S	95        gg
)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)r4   r5   _get_cudnn_enableddevicetypedtypeCUDNN_TENSOR_DTYPESr7   warningswarnr.   formatr"   sysplatform)tensors    r   is_acceptablerI   f   s    88&&((}}V#v||;N'N>>N	
 77BII#6HLLLL"3 J 	
 r/   c                    [         R                  R                  5       [         R                  R                  5       [	        5       (       d  S O[         R                  R                  5       [         R                  R                  5       [         R                  R                  5       4nU b  [         R                  R                  U 5        Ub  [         R                  R                  U5        Ub.  [	        5       (       a  [         R                  R                  U5        Ub  [         R                  R                  U5        Ub  [         R                  R                  U5        U$ r   )r4   r5   r>   _get_cudnn_benchmarkr7   _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_flagsrZ   }   s     	##%%%' NN(P(P(R))+&&(J ##H-%%j1#001AB!)).9&&{3r/   c              #   2  #    [        5          [        XX#U5      nS S S 5         S v   [        5          [        W6   S S S 5        g ! , (       d  f       N/= f! , (       d  f       g = f! [        5          [        W6   S S S 5        f ! , (       d  f       f = f= f7fr   )r   rZ   )enabled	benchmarkbenchmark_limitdeterministic
allow_tf32rY   s         r   flagsra      sn      
'	(


 
)# +,z" -, 
)	( -,*,z" -,,s_   BABA& 
B	A	B
AB
A#B&B1	B:	B
BBBc                   .  ^  \ rS rSrU 4S jr\" \R                  R                  \R                  R                  5      r
\" \R                  R                  \R                  R                  5      r\" \R                  R                  \R                  R                  5      rSr\" 5       (       a1  \" \R                  R&                  \R                  R(                  5      r\" \R                  R*                  \R                  R,                  5      rSrU =r$ )CudnnModule   c                 $   > [         TU ]  X5        g r   )super__init__)selfmname	__class__s      r   rg   CudnnModule.__init__   s    !r/   Nr   )__name__
__module____qualname____firstlineno__rg   r   r4   r5   r>   rO   r\   rM   rR   r_   rK   rP   r]   r^   r7   rL   rQ   rN   rS   r`   __static_attributes____classcell__)rk   s   @r   rc   rc      s    " %((55uxx7R7RSG))588+L+LM %%uxx'D'DI O~~%HH44HH44
 &&(F(FJr/   rc   r\   r_   r]   r`   r^   )NNNNN)FF
   FT) r    rF   rC   
contextlibr   typingr   r4   torch.backendsr   r   r   torch._Cr   ImportErrorr	   int__annotations__r.   r2   halffloatdoublerB   r7   rI   rZ   ra   rc   modulesrm   boolr   r/   r   <module>r      s   	 
  %   Q Q "&# %	0h 
JJ	KK	LL 
0 6 # #0* 0 $CKK$98DH  
   E  Fs   C CC