
    `ie-                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZej        j	        j
        j        Zd Z G d de          Z G d d          Zddd	Zd
 Zd ZdS )    Nc                 Z    	  |             S # |$ r}t          |          cY d }~S d }~ww xY wN)repr)funcerrorses      b/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/_runtime.py_eval_or_errorr
      sF    tvv   Awws   	 *%**c                        e Zd Zd Zd Zd ZdS )_InstallInfoc                 P   |                                  }||t          j                            |d          }t	          t          j                            |d                    t	          t          j                            |d                    d}nd d d}|| _        || _        d S )Nz.datalibinclude)r   r   )_get_cupy_package_rootospathjoin_dir_or_nonecupy_package_root
data_paths)selfr   	data_rootr   s       r	   __init__z_InstallInfo.__init__   s     7799(%6@@I#BGLLE$B$BCC'Y	(J(JKK JJ  J
 "3$    c                 r    || j         vr"t          d                    |                    | j         |         S )NzInvalid data type: {})r   
ValueErrorformat)r   	data_types     r	   get_data_pathz_InstallInfo.get_data_path/   s9    DO++4;;IFFGGGy))r   c                     	 t          j        t                    }n# t          $ r Y d S w xY wt          j                            |          S r   )inspectgetfilecupy	TypeErrorr   r   dirname)r   	cupy_paths     r	   r   z#_InstallInfo._get_cupy_package_root4   sN    	--II 	 	 	44	wy)))s    
**N)__name__
__module____qualname__r   r   r    r   r	   r   r      sA        % % %"* * *
* * * * *r   r   c                       e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdddZd ZdS )_RuntimeInfoNTfullc                   t           j        | _        t          s$t           j                                        | _        n#t           j                                        | _        t          s$t           j        	                                | _
        n#t           j                                        | _
        t          t           j        j                                                  | _        t           j        j                                        rA	 dd l}|j        j        }n# t&          $ r dd l}|j        }Y nw xY w| xj        d| dz  c_        t)          t           j        j        j        t           j        j        j                  | _        t)          t           j        j        j        t           j        j        j                  | _        t)          t           j        j        t8                    | _        d| _        |rt)          d t8                    | _        	 ddlm  t)          fdt8                    | _!        n# t&          $ r Y nw xY wt)          d t8                    | _"        t)          d	 t8                    | _#        d| _$        |rt)          d
 t8                    | _$        t)          d t8                    | _%        	 dd l&mc m'} |                                | _(        n# t&          $ r Y nw xY wt          sf	 t           j        j)        *                                }n# t8          $ r d }Y nw xY w|d| _+        n%t          t          j        j,        |           | _+        t           j        -                    d          r5|r t           j        .                    d           nd| _/        | j/        | _0        	 dd l1mc m2c m3} |                                | _/        t)          |j*        |j4                  | _0        n# t&          $ r Y nw xY wt           j        -                    d          r5|r t           j        .                    d           nd| _5        | j5        | _6        	 dd l7mc m2c m8} |                                | _5        |9                                }|dk    rd}|| _6        n# t&          $ r Y nw xY wt           j        j:                                        | _;        	 dd l<mc m=}	 |	                                | _>        n# t&          $ r Y nw xY w	 dd l?mc m2c m@}
 |
9                                | _A        n# t&          $ r Y nw xY w	 dd lBmc m2c mC} |                                | _D        n# t&          $ r Y nw xY wt           jE        jF        | _G        	 dd lH}|j        | _I        n# t&          $ r Y nw xY wt          jK        jL        | _M        	 dd lN}|jK        jL        | _O        d S # t&          $ r Y d S w xY w)Nr   z (CUDA Python: )z(available)c                      t           j        j                            t           j        j                                                  S r   )r#   cudacublas
getVersiondeviceget_cublas_handler*   r   r	   <lambda>z'_RuntimeInfo.__init__.<locals>.<lambda>   s/    	(33I$6688: : r   cufftc                  ,                                      S r   )r4   r8   s   r	   r7   z'_RuntimeInfo.__init__.<locals>.<lambda>   s    ((** r   c                  H    t           j        j                                        S r   )r#   r2   curandr4   r*   r   r	   r7   z'_RuntimeInfo.__init__.<locals>.<lambda>   s    DI$//11 r   c                  H    t           j        j                                        S r   )r#   r2   cusolver_getVersionr*   r   r	   r7   z'_RuntimeInfo.__init__.<locals>.<lambda>   s    DI&2244 r   c                      t           j        j                            t           j        j                                                  S r   )r#   r2   cusparser4   r5   get_cusparse_handler*   r   r	   r7   z'_RuntimeInfo.__init__.<locals>.<lambda>   s/    	*55I$88::< < r   c                  H    t           j        j                                        S r   )r#   r2   nvrtcr4   r*   r   r	   r7   z'_RuntimeInfo.__init__.<locals>.<lambda>   s    DIO..00 r   z(NVRTC unavailable)cudnnz0(not loaded; try `import cupy.cuda.cudnn` first)ncclz/(not loaded; try `import cupy.cuda.nccl` first)z	(unknown))Pr#   __version__cupy_versionis_hipr2   get_cuda_path	cuda_path_environmentget_rocm_pathget_nvcc_path	nvcc_pathget_hipcc_pathstrdriverget_build_versioncuda_build_version_is_cuda_pythoncuda.bindingsbindingsImportErrorr
   runtimedriverGetVersionCUDARuntimeErrorcuda_driver_versionruntimeGetVersioncuda_runtime_versionget_local_runtime_version	Exceptioncuda_local_runtime_versioncublas_version	cupy.cudar9   cufft_versioncurand_versioncusolver_versioncusparse_versionnvrtc_versioncupy.cuda.thrustthrustthrust_versionrD   r4   cuda_extra_include_dirs$_get_include_dir_from_conda_or_wheel_can_attempt_preload_preload_librarycudnn_build_versioncudnn_versioncupy_backends.cuda.libs.cudnnlibsrE   
CuDNNErrornccl_build_versionnccl_runtime_versioncupy_backends.cuda.libs.ncclrF   get_versioncubcub_build_versioncupy.cuda.jitifyjitifyjitify_build_version cupy_backends.cuda.libs.cutensorcutensorcutensor_version"cupy_backends.cuda.libs.cusparselt
cusparseltcusparselt_version_utilcython_build_vercython_build_versionCythoncython_versionnumpyversionfull_versionnumpy_versionscipyscipy_version)r   r.   r2   cuda_versionrj   rh   rE   rF   rv   r|   r   r   r   r   r9   s                 @r	   r   z_RuntimeInfo.__init__b   s    , 	?!Y4466DNN!.<<>>DN 	@!.<<>>DNN!.==??DN #&di&6&H&H&J&J"K"K9++-- 	I0$$$$#}8 0 0 0#/0 ##'H'H'H'HH###1I.I.$0 $0 
 %3I/I.%0 %0! +9I/+ +'
 , 	"0: :# #D	''''''!/****I"7 "7D 	 	 	D	 -11 
 !/44! !
 !. 	$2< <% %D! ,00 
	---------"(":":"<"<D 	 	 	D	  
	)% $	 : : < < % % % $%$/D,,/2%J&(0) 0),
 11':: 	> >!227;;;; G (%)%="	999999999999','>'>'@'@D$!/ %"2"4 "4D 	 	 	D	 11&99 	D D!226:::: F ',0,C)	777777777777&*&<&<&>&>D##'#3#3#5#5 #q(('2$(<D%% 	 	 	D	 "&!@!@!B!B	---------(.(@(@(B(BD%% 	 	 	D		????????????$,$8$8$:$:D!! 	 	 	D		CCCCCCCCCCCC&0&B&B&D&DD## 	 	 	D	 %)J$?!	MMM"("4D 	 	 	D	 #]7	LLL!&!;D 	 	 	DD	s   D D10D1#H4 4
I I:"K 
K*)K*5#L L('L(/AO4 4
P PAR" "
R/.R/"S> >
T
T%T5 5
UU%U, ,
U98U9V$ $
V10V1W" "
W0/W0c                    dt          j                     fdt          j                    fd| j        fdt          sdndfd| j        fd| j        fd	| j        fd
| j        fd| j        ft          rdnd| j	        fd| j
        fd| j        fd| j         d| j         dfd| j        fg}|d| j        fd| j        fd| j        fd| j        fd| j        fd| j        fd| j        fd| j        fd| j        fg	z  }|d| j        fd| j        fd| j        fd | j        fd!| j        fd"| j        fgz  }d#}	 t<          j        j         !                                }nL# t<          j        j         j"        $ r0}d$|j#        d#         vrtI          j%        d%|            Y d }~nd }~ww xY wtM          |          D ]0}t<          j        '                    |          5 }t<          j        j         (                    |          }d&)                    |          |d'         *                                f}d()                    |          |j+        f}t          r\	 |d)         *                                }	n(# tX          $ r d*t[          |d+                   z   }	Y nw xY wd,)                    |          |	f}	nd-)                    |          |j.        f}	|||	|gz  }d d d            n# 1 swxY w Y   2t_          d. |D                       d/z   }
d0t[          |
          z   d1z   }ta          j1                    }|D ].\  }}|2                    |)                    ||                     /|3                                S )2NOSzPython VersionzCuPy VersionzCuPy PlatformzNVIDIA CUDAzAMD ROCmzNumPy VersionzSciPy VersionzCython Build VersionzCython Runtime Versionz	CUDA Rootz
hipcc PATHz	nvcc PATHzCUDA Build VersionzCUDA Driver VersionzCUDA Runtime Versionz (linked to CuPy) / z (locally installed)zCUDA Extra Include DirszcuBLAS VersionzcuFFT VersionzcuRAND VersionzcuSOLVER VersionzcuSPARSE VersionzNVRTC VersionzThrust VersionzCUB Build VersionzJitify Build VersionzcuDNN Build VersionzcuDNN VersionzNCCL Build VersionzNCCL Runtime VersionzcuTENSOR VersionzcuSPARSELt Build Versionr   ErrorNoDevicez!Failed to detect number of GPUs: zDevice {} NamenamezDevice {} PCI Bus IDgcnArchNamegfxgcnArchzDevice {} ArchzDevice {} Compute Capabilityc                 8    g | ]}t          |d                    S )r   )len).0rs     r	   
<listcomp>z(_RuntimeInfo.__str__.<locals>.<listcomp>P  s"    0001S1YY000r      z{:z}: {}
)4platformpython_versionrH   rI   r   r   r   r   rK   rO   rT   r\   r^   ra   rl   rb   rd   re   rf   rg   rh   rk   rz   r}   rp   rq   ru   rv   r   r   r#   r2   rY   getDeviceCountr[   argswarningswarnrangeDevicegetDevicePropertiesr   decode
pci_bus_idKeyErrorrQ   compute_capabilitymaxioStringIOwritegetvalue)r   recordsdevice_countr   	device_idr5   propsr   pci_busarchwidthfmtskvs                  r	   __str__z_RuntimeInfo.__str__  s9   H%''(x6889T./6ImmzJd01d01#T%>?%t':;$.)#4\\dnE!4#:;"D$<=#, I I2I I I '(DE'
, 	t23d01t23!67!67d01t23 $"89#T%>?

 
	
 	"D$<=d01!4#:;#T%>?!67')@A
 	
 	G9,;;==LLy 1 	G 	G 	GafQi//E!EEFFF	G |,, 	1 	1I!!),, 1	)==iHH(//	::f,,..0188CC!,. 7;$]3::<<# ; ; ;$Sy)9%:%::;,33I>>EDD:AA)LL"57DD$001 1 1 1 1 1 1 1 1 1 1 1 1 1 1" 0000011A5SZZ)+KMM 	& 	&DAqGGCJJq!$$%%%%zz||sO   (#E F%&FF	A7KIK"J>K J?KK	K	)r'   r(   r)   rH   rK   rT   r\   r^   ra   rb   rd   re   rf   rg   rh   rk   rl   rp   rq   ru   rv   rz   r}   r   r   r   r   r   r   r   r   r*   r   r	   r,   r,   <   s        LI   !% NMNMN" MNMM# g g g g gRK K K K Kr   r,   Tr-   c                 "    t          |           S )Nr-   )r,   r-   s    r	   get_runtime_infor   Y  s    T""""r   c                      t                      S r   )r   r*   r   r	   get_install_infor   ]  s    >>r   c                 H    t           j                            |           r| S dS )z$Returns None if path does not exist.N)r   r   isdir)r   s    r	   r   r   a  s"    	w}}T 4r   )r!   r   r   r   r   r   r#   cupy_backendsr2   apirY   rI   r
   objectr   r,   r   r   r   r*   r   r	   <module>r      s    				 				         
			'	.  * * * * *6 * * *DZ Z Z Z Z Z Z Zz " # # # # #      r   