o
    iah                     @   s4  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mZ d dl	m	Z	 d dl
mZ d dlmZmZmZ d dlZd dlmZ d dlmZ d dlmZmZ d dlmZ d d	lmZ  d d
l!m"Z# d dl$m%Z% dZ&zd dl'Z'W n	 e(yy   Y nw dZ&ddgZ)d\Z*Z+Z,dZ-dZ.d\Z/Z0d\Z1Z2dZ3d\Z4Z5dZ6d\Z7Z8d\Z9Z:d\Z;Z<dZ=dZ>dZ?dZ@dZAd ZBd!ZCd"ZDd#ZEd$ZFd%ZGd&ZHd'ZId(\ZJZKd)ZLd*ZMd+ZNd,ZOd-ZPd.ZQd/ZRd0ZSd1\ZTZUd2ZVd3ZWd4\ZXZYd5\ZZZ[d6Z\d7\Z]Z^d8Z_d9\Z`Zad:\ZbZcd;Zdd<Zed=Zfd>Zgd?Zhg Zig Zjd@dA ZkdBd ZldFdDdZmendEkrem  dS dS )G    N)redirect_stdout)datetime)StringIO)check_outputPIPECalledProcessError)__version__)cudar   )cudadrv)driver)runtime)configFTget_sysinfodisplay_sysinfo)ZStartz	Start UTCZRuntimeNumba VersionMachine)CPU Name	CPU Count)zCPUs AllowedzList CPUs AllowedCPU Features)z	CFS Quotaz
CFS PeriodzCFS Restriction)z	Mem TotalzMem Available)Platform NamePlatform Release)OS Name
OS VersionOS Specific VersionLibc VersionzPython CompilerzPython ImplementationzPython VersionzPython Localellvmlite VersionLLVM VersionzCUDA Device InitCUDA Driver VersionCUDA Runtime VersionzNVIDIA CUDA BindingszNVIDIA CUDA Bindings In Use)zCUDA Detect OutputzCUDA Lib Testz1NVIDIA CUDA Minor Version Compatibility Availablez.NVIDIA CUDA Minor Version Compatibility Neededz.NVIDIA CUDA Minor Version Compatibility In UseNumPy VersionNumPy Supported SIMD featuresNumPy Supported SIMD dispatchNumPy Supported SIMD baselinezNumPy AVX512_SKX detected)z
SVML StatezSVML Lib LoadedzLLVM SVML PatchedSVML Operational)zTBB ThreadingzTBB Threading Error)zOpenMP ThreadingzOpenMP Threading ErrorzOpenMP vendor)zWorkqueue ThreadingzWorkqueue Threading ErrorzNumba Env Vars)zConda Buildz	Conda Env)zConda PlatformzConda Python VersionzConda Root WritablezInstalled PackageszPsutil AvailableZErrorsZWarningsc                    s  G dd dt }G dd dt }|d|df|d|dfttttttd	d
d|d|dfttdd
ddttdtdtdidd}i  || i dd}trt	
 } t|jt|ji t	 }t|drr| ng }|rt| t< ddd |D  t< ntd |dd7 }g }|D ]}	t|	drtj|	d rz1t|	d d }
|
 }|rd|	d |d f|d< || W d    n1 sw   Y  W q ty } ztd|  W Y d }~qd }~ww td |	d  qzt|	td!}W n tt fy& } ztd"|  W Y d }~qd }~ww t|	d#r;d$d%d |! D d& }||" !  qd'i }|D ]/}|# |$ @ }|rmt|dkrm||%  }| |< qMt|dkr{t&d(|  qM fd)d*} fd+d,}z|  ts|  W n t'y } ztd-|  W Y d }~nd }~ww t(d.d/ it)d0d/ it)d1d/ id}|| i } d2d3 |* D   S )4Nc                   @      e Zd ZdZdS )z&get_os_spec_info.<locals>.CmdBufferOutTN)__name__
__module____qualname__buffer_output_flag r)   r)   g/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/numba/misc/numba_sysinfo.pyCmdBufferOutq       r+   c                   @   r$   )z%get_os_spec_info.<locals>.CmdReadFileTN)r%   r&   r'   read_file_flagr)   r)   r)   r*   CmdReadFilet   r,   r.   )'/sys/fs/cgroup/cpuacct/cpu.cfs_quota_us)(/sys/fs/cgroup/cpuacct/cpu.cfs_period_us)z/proc/meminfo)z/proc/self/status)z	MemTotal:zMemAvailable:zCpus_allowed:zCpus_allowed_list:r/   r0   )cmdcmd_optionalkwdsr)   )wmicOSgetTotalVirtualMemorySize)r4   r5   r6   FreeVirtualMemory)r7   r8   ))Zsysctlz
hw.memsizeZvm_stat)zhw.memsize:zfree:   i   )r1   r2   r3   units)LinuxWindowsDarwinr1   cpu_affinity c                 s       | ]}t |V  qd S Nstr).0nr)   r)   r*   	<genexpr>       z#get_os_spec_info.<locals>.<genexpr>zWWarning (psutil): psutil cannot be imported. For more accuracy, consider installing it.r2   r-   r   rzError (file read): zWarning (no file): {})stderrzError (subprocess): r(       c                 s       | ]}|V  qd S rA   r)   )rD   liner)   r)   r*   rF      s       
r3   zAmbiguous output: c                     s     td } | rt| d  t<   td } | r$t| d  t<   tddkrB  td}  td}|| }| t< d S d S )N )r6   
_cfs_quotasplitfloat_cfs_period_cfs_restrict)rQ   Z	cfs_quotaZ
cfs_periodZruntime_amount)os_spec_infor)   r*   format   s   z get_os_spec_info.<locals>.formatc                     s   t dtdi} | di  t tfD ]}ddd  |dD }t|p'd| |   |< q td }|rU|d }|dd }tt	t|pKdd	
d
 t<  td }|rg|d  t< d S d S )Ni   r:   rN   c                 s   s    | ]	}|  r|V  qd S rA   )isdigit)rD   dr)   r)   r*   rF      s    z<get_os_spec_info.<locals>.format_optional.<locals>.<genexpr>r   rO   ,   1)
_mem_total_mem_availableupdater6   joinint_cpus_allowedrQ   rC   bincount
_cpus_list)r:   kdigitsrQ   rE   rU   paramsr)   r*   format_optional   s    z)get_os_spec_info.<locals>.format_optionalzError (format shell output): c                   S   s   d t S )Nr?   )r_   platformlibc_verr)   r)   r)   r*   <lambda>  s    z"get_os_spec_info.<locals>.<lambda>c                   S   s   d dd t D S )Nr?   c                 s   rK   rA   r)   )rD   sr)   r)   r*   rF     s    
5get_os_spec_info.<locals>.<lambda>.<locals>.<genexpr>)r_   rj   	win32_verr)   r)   r)   r*   rl     s   
 c                   S   s   d dd tt D S )NrN   c                 s   s"    | ]}|D ]}|pd V  qqdS )r?   Nr)   )rD   rm   ir)   r)   r*   rF     s    rn   )r_   tuplerj   mac_verr)   r)   r)   r*   rl     s   
 
c                 S   s   i | ]\}}|| qS r)   r)   )rD   re   fr)   r)   r*   
<dictcomp>      z$get_os_spec_info.<locals>.<dictcomp>)+rq   r\   r]   ra   rd   rP   rS   r6   _psutil_importpsutilZvirtual_memoryr^   total	availableProcesshasattrr>   lenr_   _warning_logappendospathexistsopen	readlinesextendOSError
_error_logrV   r   r   r   
splitlinesdecodekeysrQ   popprint	Exception_libc_version_os_spec_versionitems)os_namer+   r.   Zshell_paramsZcmd_selectedvmpZcpus_allowedoutputr1   rs   outer3   rL   matchre   rV   ri   Zos_specific_funcsZkey_funcr)   rg   r*   get_os_spec_infoe   s   2
r   c            %      C   s  i t t tt tt tt	
 tt ttjddtt tt tt tt tt tt tdd tj D tt t!d"dd t	j#D t$t%t&t'} zt	( }W n t)y } zt*+d|  W Y d }~nd }~ww t,d	d
 | D }d"|| t-< zd"dd
 t./ D | t0< W n t1y } zt*+d|  W Y d }~nd }~ww zt23 d  W nW t1y } zJd| t4< d}d}d}d}t5|dd }|d ur||v r|| }	n||v r|| }	n|d | }	n|d t6| }	t7+d|	t6t8|f  W Y d }~nd }~ww zd| t4< t9 }
t:|
 t2;  W d    n	1 s:w   Y  |
< | t=< |
>  t?@ }tA@ }d| | tB< d| | tC< t9 }
t:|
 tDjEF  W d    n	1 suw   Y  |
< | tG< |
>  z
ddlHmH} d}W n tIy   d}Y nw || tJ< tKtDjLjM}|| tN< zddlOmP} ddlQmR} d| tS< W n tIy   d| tS< Y nw ||k| tT< tKtUjV| tW< W n  t1y } zt7+dt8| d|  W Y d }~nd }~ww tXjjY| tZ< zddl[m\}m]}m^} W n tIy   d| t_< Y nw dd
 | D }|| t`< || ta< || tb< |cdd| t_< d}z+tdjed rGt	fd! ntdjed"rTt	fd# ntdjed$rat	fd% nd}W n t1yp   d}Y nw t5t	jgd&d }|r~| nd| th< tUji| tj< || tk< tl| tj | tk | th f| tm< d'd( }zdd)lnmo} dd*lpmq} |  d| tr< W n tIy } zd| tr< ||d+| ts< W Y d }~nd }~ww zdd,lnmt} d| tu< |jv| tw< W n tIy } zd| tu< ||d-| tx< W Y d }~nd }~ww zdd.lnmy} d| tz< W n tIy, } zd| tz< ||d/| t{< W Y d }~nd }~ww d0}zt||}W nM t1y } z@t7+d1| d2 tdj}d3d4d5f}zt||}W n t1yo } zt*+d6|  W Y d }~nd }~ww |~  | t< W Y d }~nYd }~ww t|~ } tttttd7}!|! D ]\}"}#| c|"d8| |#< qd9}zt||}W n ty } zt*+d:|  W Y d }~nd }~ww |~  }$d;d
 |$D | t< | t| t  t*| t< t7| t< t | t    | t< | S )<NT)aliasedc                 S       i | ]\}}| d r||qS )ZNUMBA_
startswithrD   re   vr)   r)   r*   rt   3      zget_sysinfo.<locals>.<dictcomp>.c                 s   r@   rA   rB   rD   rp   r)   r)   r*   rF   6  rG   zget_sysinfo.<locals>.<genexpr>zError (CPU features): c                 S      g | ]\}}|r|qS r)   r)   )rD   keyvaluer)   r)   r*   
<listcomp>A  ru   zget_sysinfo.<locals>.<listcomp>r?   c                 S   s   g | ]}t |qS r)   rB   r   r)   r)   r*   r   I      zError (locale): r   Fz#CUDA driver library cannot be foundzCUDA is disabledz( or no CUDA enabled devices are present.z#CUDA device initialisation problem.msgz	 Message:z&Warning (cuda): %s
Exception class: %sz%s.%s)r	   )compile_ptx)CubinLinkerzYWarning (cuda): Probing CUDA failed (device and driver present, runtime problem?)
(cuda) z: )__cpu_features____cpu_dispatch____cpu_baseline__c                 S   r   r)   r)   r   r)   r)   r*   r     ru   Z
AVX512_SKXlinuxz
libsvml.sodarwinzlibsvml.dylibwinZsvml_dispmdZhas_svmlc                 S   s^   z$dd | j dD \}}}tj|d }||v r"d||f W S W dS  ty.   Y dS w )Nc                 S   s   g | ]}|  qS r)   )strip)rD   xr)   r)   r*   r     r   z4get_sysinfo.<locals>.parse_error.<locals>.<listcomp>:r9   z%s: %szUnknown import problem.)r   rQ   r   r   r   )r   backendr   problemsymbolZextn_dsor)   r)   r*   parse_error  s   z get_sysinfo.<locals>.parse_error)tbbpool)_check_tbb_version_compatibler   )omppoolr   )	workqueuer   )condainfoz--jsonz)Warning: Conda not available.
 Error was 
z-mpiplistzError (pip): )Zconda_build_versionZconda_env_versionrj   python_versionZroot_writablezN/A)r   r   zError (conda): c                 S   s   g | ]	}| d s|qS )#r   )rD   lr)   r)   r*   r     s    )_startr   now
_start_utcutcnow_machinerj   machine	_cpu_namellvmbindZget_host_cpu_name
_cpu_countmultiprocessing	cpu_count_platform_name_platform_releaserelease_os_namesystem_os_versionversion_python_comppython_compiler_python_implpython_implementation_python_versionr   _numba_env_varsr   environr   _numba_versionversion_number_llvm_versionr_   Zllvm_version_info_llvmlite_versionllvmlite_version_psutilrv   Zget_host_cpu_featuresRuntimeErrorr   r~   sorted_cpu_featureslocalegetdefaultlocale_python_localer   cuZlist_devices_cu_dev_initgetattrrC   r}   typer   r   detectgetvalue_cu_detect_outclosecudriverget_version	curuntime_cu_drv_ver
_cu_rt_verr
   Zlibstest_cu_lib_testr	   ImportError_cu_nvidia_bindingsboolr   ZUSE_NV_BINDING_cu_nvidia_bindings_usedZptxcompilerr   Zcubinlinkerr   _cu_mvc_available_cu_mvc_neededr   Z'CUDA_ENABLE_MINOR_VERSION_COMPATIBILITY_cu_mvc_in_usenpZfull_version_numpy_versionZnumpy.core._multiarray_umathr   r   r   _numpy_AVX512_SKX_detected_numpy_supported_simd_features_numpy_supported_simd_dispatch_numpy_supported_simd_baseliner6   sysr   Zload_library_permanentlytargets_llvm_svml_patchedZ
USING_SVML_svml_state_svml_loadedall_svml_operationalZnumba.np.ufuncr   Znumba.np.ufunc.parallelr   _tbb_thread
_tbb_errorr   _openmp_threadZopenmp_vendor_openmp_vendor_openmp_errorr   _wkq_thread
_wkq_errorr   
executabler   r   	_inst_pkgjsonloads_conda_build_ver_conda_env_ver_conda_platform_conda_python_ver_conda_root_writabler   r^   r   _errors	_warningstotal_seconds_runtime)%Zsys_infoZfeature_mapr   featuresZmsg_not_foundZmsg_disabled_by_userZmsg_endZmsg_generic_problemr   err_msgr   Z
cu_drv_verZ	cu_rt_verr	   Znvidia_bindings_availableZnv_binding_usedr   r   r   r   r   Zfeat_filteredZsvml_lib_loadedfuncr   r   r   r   r   r1   Z	conda_outreqsZjsondr   Zconda_kZ	sysinfo_kdatar)   r)   r*   r   #  s  	









-   c           	         s  G dd dt }G dd dt}G dd dt}| d u rt } d d d	}g d
dd| tdfd| tdfd| tdfddd| tdfd| tdfd| t	dfd| t
dfd| tdfd| tdfdddfddttj| tdd dD fdd| td | pdf| td!d"ks| td#rd$nd%| td | pdfdd&d'| tdfd(| tdfd)| tdfd*| tdfd+| tdfd,| tdfdd-|d.d/ |  D dd0d1| tdfd2| tdfdd3d4| tdfdd5d6| tdfd7| t dfd8| t!dfd9| t"dfd:| t#dfd;| t$dfd<| t%dfd=| t&dfd>| t'dfd?| t(dfdd@dA| t)dfdB|| t*g pdCfdD|| t+g pdCfdE|| t,g pdCfdF| t-dfddGdH| t.dfdI| t/dfdJ| t0dfdK| t1dfddLdM| t2df| t2drdNndO| t3d fdP| t4df| t4d#rdQ| t5d ndO| t6d fdR| t7df| t7d#r)dSndO| t8d fddT|| t9i pAdCddU|dVd/ |  D pSdWddX|| t:dYd| t;g rkdZnd[f|| t;g d| t<g rd\nd]f|| t<g d
d^R }|D ]`}t=|d_rt>|d`di qt=|dart>t fdbd| D d`di qt=|dcr|D ]}t>t fddd| D ddde qǐqt?|dfkrt> |  qt>|  qd S )gNc                   @   r$   )z#display_sysinfo.<locals>.DisplayMapTN)r%   r&   r'   display_map_flagr)   r)   r)   r*   
DisplayMap  r,   r%  c                   @   r$   )z#display_sysinfo.<locals>.DisplaySeqTN)r%   r&   r'   display_seq_flagr)   r)   r)   r*   
DisplaySeq  r,   r'  c                   @   r$   )z'display_sysinfo.<locals>.DisplaySeqMapsTN)r%   r&   r'   display_seqmaps_flagr)   r)   r)   r*   DisplaySeqMaps  r,   r)  z%-zs : %-si   )zP--------------------------------------------------------------------------------)z__Time Stamp__zReport started (local time)?zUTC start timezRunning time (s))rN   )z__Hardware Information__r   r   r   zNumber of accessible CPUszList of accessible CPUs coresz(CFS Restrictions (CPUs worth of runtime)Noner   r   c                 3   s,    | ]\}}|rd  d  | n|V  qdS )r?      Nr)   )rD   rp   r   )sep_posr)   r*   rF   3  s
    
z"display_sysinfo.<locals>.<genexpr>O   )widthzMemory Total (MB)r   rN   r=   FzMemory Available (MB)zFree Memory (MB))z__OS Information__r   r   r   r   r   r   )z__Python Information__c                 S   r   )Pythonr   r   r)   r)   r*   rt   K  s     z#display_sysinfo.<locals>.<dictcomp>)z__Numba Toolchain Versions__r   r   )z__LLVM Information__r   )z__CUDA Information__zCUDA Device Initializedr   r   zCUDA NVIDIA Bindings AvailablezCUDA NVIDIA Bindings In Usez*CUDA Minor Version Compatibility Availablez'CUDA Minor Version Compatibility Neededz'CUDA Minor Version Compatibility In Use)zCUDA Detect Output:)zCUDA Libraries Test Output:)z__NumPy Information__r   r    )zNone found.r!   r"   z!NumPy AVX512_SKX support detected)z__SVML Information__zSVML State, config.USING_SVMLzSVML Library Loadedz llvmlite Using SVML Patched LLVMr#   )z__Threading Layer Information__zTBB Threading Layer Availablez+-->TBB imported successfully.z+--> Disabled due to z OpenMP Threading Layer Availablez+-->Vendor: z#Workqueue Threading Layer Availablez$+-->Workqueue imported successfully.)z*__Numba Environment Variable Information__)z__Conda Information__c                 S   r   )ZCondar   r   r)   r)   r*   rt     r   )zConda not available.)z__Installed Packages__)z Couldn't retrieve packages info.z__Error log__zNo errors reported.z__Warning log__zNo warnings reported.)a  If requested, please copy and paste the information between
the dashed (----) lines, or from a given specific section as
appropriate.

=============================================================
IMPORTANT: Please ensure that you are happy with sharing the
contents of the information present, any information that you
wish to keep private you should remove before sharing.
=============================================================
r&  sepr$  c                 3   s     | ]\}} ||f V  qd S rA   r)   r   fmtr)   r*   rF     s    r(  c                 3   s$    | ]\}} d | |f V  qdS )	Nr)   r   r2  r)   r*   rF     s   " )r1  end   )@dictrq   r   r6   r   r   r  r   r   r   ra   rd   rT   r_   	enumeratetextwrapwrapr   r\   r   r   r]   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r  r  r	  r
  r  r  r  r  r  r  r   r  r  r  r{   r   r|   )	r   r-  r%  r'  r)  MBtemplatetrX   r)   )r3  r-  r*   r     s  	


 !"#$%&'()*+,-./0123456
8
:
<
>?@ABCDEHKN
PQRSTUVWXY[
]_`bcdefgijklmopqstu~(__main__)Nr#  )or  r   r   r   rj   r9  r  
contextlibr   r   ior   
subprocessr   r   r   numpyr   Zllvmlite.bindingZbindingr   Zllvmliter   r   Znumbar	   r   r   Z
numba.cudar
   Znumba.cuda.cudadrv.driverr   r   Znumba.cuda.cudadrv.runtimer   r   Z
numba.corer   rv   rw   r   __all__r   r   r  r   r   r   r   ra   rd   r   rP   rS   rT   r\   r]   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r  r  r  r	  r
  r  r  r  r  r  r  r   r  r  r  r  r  r  r   r  r  r   r}   r   r   r   r%   r)   r)   r)   r*   <module>   s    
 ? 
r 

