
    %Vji@                        U d dl Z d dlZd dlZd dlmZ d dlmZ d dlZd dlm	Z	m
Z
mZmZmZmZ 	 d dlmZ n# e$ r dZY nw xY wdaee         ed<   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j         e!         e!          ej         e!<   e"ed<   e"ed<   e"ed<   e"ed<   eed<   dS )    N)contextmanager)Optional)__allow_nonbracketed_mutation_FP32Precision_get_fp32_precision_getter_set_fp32_precision_setterContextProp
PropModule)_cudnn__cudnn_versionc                  P  	 t           t          j                    a t          j                    } t          j                    }| \  }}}|\  }}}||k    rd}n|dk     st          j        s||k    }n||k    }|st          j                            dd          dk    rdS d| d|  d	}d
t          j        v rat          j                            d
d          	t          	fddD                       rt          | d|           t          | d          t          |          dS )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 V  	d S N ).0	substringld_library_paths     W/root/voice-cloning/.venv/lib/python3.11/site-packages/torch/backends/cudnn/__init__.py	<genexpr>z_init.<locals>.<genexpr>A   s9        9B	_4         )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   _initr1   "   s   "$244O$688O$688O.=+M=!.=+M=! --#(  ""&."#0M#A  #0M#A # 7:>>"JCPPTWWW445D4 41@4 4 4  %
22&(jnn5F&K&KO    FW      +- h hVeh h   +- E E E   '~666tr   c                      dS )NFr   r   r   r   r1   r1   V   s    ur   c                  0    t                      sdS t          S )zReturn the version of cuDNN.N)r1   r   r   r   r   versionr4   Z   s    77 tr   c                  $    t           j        j        S )z9Return a bool indicating if CUDNN is currently available.)torch_C
_has_cudnnr   r   r   is_availabler9   h   s    8r   c                    t           j                                        sdS | j        j        dk    s| j        t          vrdS t                      st          j	        d           dS t                      sKt          j	        d                    ddd                    t          j        d          	                     dS d
S )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)r6   r7   _get_cudnn_enableddevicetypedtypeCUDNN_TENSOR_DTYPESr9   warningswarnr1   formatr%   sysplatform)tensors    r   is_acceptablerK   m   s    8&&(( u}V##v|;N'N'Nu>> N	
 	
 	
 u77 BII#6HHLLL"3  J  	
 	
 	
 u4r   nonec           	      6   t           j                                        t           j                                        t	                      sd nt           j                                        t           j                                        t           j                                        t           j                            dd          f}| t           j        	                    |            |t           j        
                    |           |-t	                      rt           j                            |           |t           j                            |           |t           j                            |           |!t           j                            dd|           |S )Nr   all)r6   r7   r@   _get_cudnn_benchmarkr9   _cuda_get_cudnn_benchmark_limit_get_cudnn_deterministic_get_cudnn_allow_tf32r   _set_cudnn_enabled_set_cudnn_benchmark_cuda_set_cudnn_benchmark_limit_set_cudnn_deterministic_set_cudnn_allow_tf32r   )_enabled
_benchmark_benchmark_limit_deterministic_allow_tf32_fp32_precision
orig_flagss          r   	set_flagsr_      s@    	##%%%%'' NNR(P(P(R(R))++&&((++FE::J ##H---%%j111##001ABBB!)).999&&{333"++FE?KKKr   F
   Tc           	   #   P  K   t                      5  t          | |||||          }d d d            n# 1 swxY w Y   	 d V  t                      5  t          |  d d d            d S # 1 swxY w Y   d S # t                      5  t          |  d d d            w # 1 swxY w Y   w xY wr   )r   r_   )enabled	benchmarkbenchmark_limitdeterministic
allow_tf32fp32_precisionr^   s          r   flagsrh      s      
'	(	( 
 

 


 
 
 
 
 
 
 
 
 
 
 
 
 
 
# +,, 	# 	#z""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#*,, 	# 	#z""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#sM   266A4 
A''A+.A+4B%
BB%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            r  eej        j        ej        j                  Z eej        j        ej        j                  Z edd          Z edd          Z e edd           edd                    Z xZS )CudnnModulec                 L    t                                          ||           d S r   )super__init__)selfmname	__class__s      r   rm   zCudnnModule.__init__   s#    D!!!!!r   Nr   convrnnrN   )__name__
__module____qualname__rm   r	   r6   r7   r@   rS   rb   rQ   rV   re   rO   rT   rc   rd   r9   rP   rU   rR   rW   rf   r   rr   rs   r   r   rg   __classcell__)rq   s   @r   rj   rj      s8       " " " " " k%(5ux7RSSGK)58+L M %ux'D I O|~~ 
%+H4H4
 
 &(F J >&&))D
.
'
'C [""6511""6511 NNNNNr   rj   rb   re   rc   rf   rd   )NNNNNrL   )FFr`   FTrL   )#r#   rH   rE   
contextlibr   typingr   r6   torch.backendsr   r   r   r   r	   r
   torch._Cr   ImportErrorr   int__annotations__r1   r4   halffloatdoublerD   r9   rK   r_   rh   rj   modulesrt   boolr   r   r   <module>r      sF   					 



  % % % % % %                         FFF "&# % % %	0 0 0 0h     
J	K	L   
  0    > # # # #<    *   < $CK$98DDH  
           s   6 A A 