o
    8ήcd                     @   s(  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.\ZQZRd/ZSd0ZTd1\ZUZVd2\ZWZXd3ZYd4\ZZZ[d5Z\d6\Z]Z^d7\Z_Z`d8Zad9Zbd:Zcd;Zdd<Zeg Zfg Zgd=d> Zhd?d ZidCdAdZjekdBkrej  dS dS )D    N)redirect_stdout)datetime)StringIO)check_outputPIPECalledProcessError)__version__)cudar   )cudadrv)driver)runtime)configFTget_sysinfodisplay_sysinfo)Startz	Start UTC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 Test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 AvailableErrors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-   ?/tmp/pip-target-vg8gfxp4/lib/python/numba/misc/numba_sysinfo.pyCmdBufferOutn       r/   c                   @   r(   )z%get_os_spec_info.<locals>.CmdReadFileTN)r)   r*   r+   read_file_flagr-   r-   r-   r.   CmdReadFileq   r0   r2   )'/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:r3   r4   )cmdcmd_optionalkwdsr-   )wmicOSgetTotalVirtualMemorySize)r8   r9   r:   FreeVirtualMemory)r;   r<   ))sysctlz
hw.memsizevm_stat)zhw.memsize:zfree:   i   )r5   r6   r7   units)LinuxWindowsDarwinr5   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.r6   r1   r   rzError (file read): zWarning (no file): {})stderrzError (subprocess): r,       c                 s       | ]}|V  qd S rG   r-   )rJ   liner-   r-   r.   rL      s       
r7   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 )r:   
_cfs_quotasplitfloat_cfs_period_cfs_restrict)rW   	cfs_quota
cfs_period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@   rT   c                 s   s    | ]	}|  r|V  qd S rG   )isdigit)rJ   dr-   r-   r.   rL      s    z<get_os_spec_info.<locals>.format_optional.<locals>.<genexpr>r   rU   ,   1)
_mem_total_mem_availableupdater:   joinint_cpus_allowedrW   rI   bincount
_cpus_list)r@   kdigitsrW   rK   r^   paramsr-   r.   format_optional   s    z)get_os_spec_info.<locals>.format_optionalzError (format shell output): c                   S   s   d t S )NrE   )rh   platformlibc_verr-   r-   r-   r.   <lambda>  s    z"get_os_spec_info.<locals>.<lambda>c                   S   s   d dd t D S )NrE   c                 s   rQ   rG   r-   )rJ   sr-   r-   r.   rL     s    
5get_os_spec_info.<locals>.<lambda>.<locals>.<genexpr>)rh   rs   	win32_verr-   r-   r-   r.   ru     s   
 c                   S   s   d dd tt D S )NrT   c                 s   s"    | ]}|D ]}|pd V  qqdS )rE   Nr-   )rJ   rv   ir-   r-   r.   rL     s    rw   )rh   tuplers   mac_verr-   r-   r-   r.   ru     s   
 
c                 S   s   i | ]\}}|| qS r-   r-   )rJ   rn   fr-   r-   r.   
<dictcomp>      z$get_os_spec_info.<locals>.<dictcomp>)+rz   re   rf   rj   rm   rV   rY   r:   _psutil_importpsutilvirtual_memoryrg   total	availableProcesshasattrrD   lenrh   _warning_logappendospathexistsopen	readlinesextendOSError
_error_logr_   r   r   r   
splitlinesdecodekeysrW   popprint	Exception_libc_version_os_spec_versionitems)os_namer/   r2   shell_paramscmd_selectedvmpcpus_allowedoutputr5   r|   outer7   rR   matchrn   r_   rr   os_specific_funcskey_funcr-   rp   r.   get_os_spec_infob   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=< |
>  dt?@  | tA< dtB@  | tC< t9 }
t:|
 tDjEjFtGjdd W d    n	1 suw   Y  |
< | tH< |
>  z
ddlImI} d}W n tJy   d}Y nw || tK< tLtDjMjN}|| tO< W n  t1y } zt7+dt8| d|  W Y d }~nd }~ww tPjjQ| tR< zddlSmT}mU}mV} W n tJy   d| tW< Y nw dd
 | D }|| tX< || tY< || tZ< |[dd| tW< d}z+tGj\drt	]d  ntGj\d!r&t	]d" ntGj\d#r3t	]d$ nd}W n t1yB   d}Y nw t5t	j^d%d }|rP| nd| t_< t`ja| tb< || tc< td| tb | tc | t_ f| te< d&d' }zdd(lfmg} dd)lhmi} |  d| tj< W n tJy } zd| tj< ||d*| tk< W Y d }~nd }~ww zdd+lfml} d| tm< |jn| to< W n tJy } zd| tm< ||d,| tp< W Y d }~nd }~ww zdd-lfmq} d| tr< W n tJy } zd| tr< ||d.| ts< W Y d }~nd }~ww d/}ztt|}W nM t1yT } z@t7+d0| d1 tGjud2d3d4f}ztt|}W n t1yA } zt*+d5|  W Y d }~nd }~ww |v w | tx< W Y d }~nYd }~ww tyz|v }t{t|t}t~td6}| D ]\}}|[|d7| |< qhd8}ztt|}W n ty } zt*+d9|  W Y d }~nd }~ww |v w } d:d
 | D | tx< | t| t  t*| t< t7| t< t | t    | t< | S );NT)aliasedc                 S       i | ]\}}| d r||qS )NUMBA_
startswithrJ   rn   vr-   r-   r.   r}   0      zget_sysinfo.<locals>.<dictcomp>.c                 s   rF   rG   rH   rJ   ry   r-   r-   r.   rL   3  rM   zget_sysinfo.<locals>.<genexpr>zError (CPU features): c                 S      g | ]\}}|r|qS r-   r-   )rJ   keyvaluer-   r-   r.   
<listcomp>>  r~   zget_sysinfo.<locals>.<listcomp>rE   c                 S   s   g | ]}t |qS r-   rH   r   r-   r-   r.   r   F      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)print_paths)r	   zYWarning (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     r~   
AVX512_SKXlinuxz
libsvml.sodarwinzlibsvml.dylibwinsvml_dispmd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)rJ   xr-   r-   r.   r     r   z4get_sysinfo.<locals>.parse_error.<locals>.<listcomp>:r?   z%s: %szUnknown import problem.)r   rW   r   r   r   )r   backendr   problemsymbol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): )conda_build_versionconda_env_versionrs   python_versionroot_writablezN/A)r   r   zError (conda): c                 S   s   g | ]	}| d s|qS )#r   )rJ   lr-   r-   r.   r     s    )_startr   now
_start_utcutcnow_machiners   machine	_cpu_namellvmbind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_versionrh   llvm_version_info_llvmlite_versionllvmlite_version_psutilr   get_host_cpu_featuresRuntimeErrorr   r   sorted_cpu_featureslocalegetdefaultlocale_python_localer   culist_devices_cu_dev_initgetattrrI   r   typer   r   detectgetvalue_cu_detect_outclosecudriverget_version_cu_drv_ver	curuntime
_cu_rt_verr
   libstestsys_cu_lib_testr	   ImportError_cu_nvidia_bindingsboolr   USE_NV_BINDING_cu_nvidia_bindings_usednpfull_version_numpy_versionnumpy.core._multiarray_umathr   r   r   _numpy_AVX512_SKX_detected_numpy_supported_simd_features_numpy_supported_simd_dispatch_numpy_supported_simd_baseliner:   r   load_library_permanentlytargets_llvm_svml_patchedr   
USING_SVML_svml_state_svml_loadedall_svml_operationalnumba.np.ufuncr   numba.np.ufunc.parallelr   _tbb_thread
_tbb_errorr   _openmp_thread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   rg   r   _errors	_warningstotal_seconds_runtime)!sys_infofeature_mapr   featuresmsg_not_foundmsg_disabled_by_usermsg_endmsg_generic_problemr   err_msgr   r	   nvidia_bindings_availablenv_binding_usedr   r   r   feat_filteredsvml_lib_loadedfuncr   r   r   r   r   r5   	conda_outreqsjsondr   conda_k	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d=d>| t&dfd?|| t'g pvd@fdA|| t(g pd@fdB|| t)g pd@fdC| t*dfddDdE| t+dfdF| t,dfdG| t-dfdH| t.dfddIdJ| t/df| t/drdKndL| t0d fdM| t1df| t1d#rdN| t2d ndL| t3d fdO| t4df| t4d#rdPndL| t5d fddQ|| t6i p)d@ddR|dSd/ |  D p;dTddU|| t7dVd| t8g rSdWndXf|| t8g d| t9g ridYndZf|| t9g d
d[R }|D ]`}t:|d\rt;|d]di q|t:|d^rt;t fd_d| D d]di q|t:|d`r|D ]}t;t fdad| D dddb qq|t<|dckrt; |  q|t;|  q|d S )dNc                   @   r(   )z#display_sysinfo.<locals>.DisplayMapTN)r)   r*   r+   display_map_flagr-   r-   r-   r.   
DisplayMap  r0   rS  c                   @   r(   )z#display_sysinfo.<locals>.DisplaySeqTN)r)   r*   r+   display_seq_flagr-   r-   r-   r.   
DisplaySeq  r0   rU  c                   @   r(   )z'display_sysinfo.<locals>.DisplaySeqMapsTN)r)   r*   r+   display_seqmaps_flagr-   r-   r-   r.   DisplaySeqMaps  r0   rW  z%-zs : %-si   )zP--------------------------------------------------------------------------------)z__Time Stamp__zReport started (local time)?zUTC start timezRunning time (s))rT   )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 )rE      Nr-   )rJ   ry   r   )sep_posr-   r.   rL   #  s
    
z"display_sysinfo.<locals>.<genexpr>O   )widthzMemory Total (MB)r   rT   rC   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.   r}   ;  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 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   )Condar   r   r-   r-   r.   r}   t  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.
=============================================================
rT  seprR  c                 3   s     | ]\}} ||f V  qd S rG   r-   r   fmtr-   r.   rL     s    rV  c                 3   s$    | ]\}} d | |f V  qdS )	Nr-   r   ra  r-   r.   rL     s   " )r`  end   )=dictrz   r   r:   r   r   r=  r   r   r   rj   rm   rZ   rh   	enumeratetextwrapwrapr   re   r   r   rf   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/  r0  r   r2  r:  r;  r   r   r   )	r   r[  rS  rU  rW  MBtemplatetra   r-   )rb  r[  r.   r     s  	



 !"#$%&'()*+,-./0123456
89:;<=>?BEH
JKLMNOPQRSU
WYZ\]^_`acdefgijkmnox(__main__)NrQ  )lr3  r   r   r   rs   rh  r  
contextlibr   r   ior   
subprocessr   r   r   numpyr  llvmlite.bindingbindingr   llvmliter   r   numbar	   r   r   
numba.cudar
   numba.cuda.cudadrv.driverr   r	  numba.cuda.cudadrv.runtimer   r  
numba.corer   r   r   r  __all__r   r   r=  r   r   r   r   rj   rm   r   rV   rY   rZ   re   rf   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/  r0  r   r5  r6  r7  r8  r9  r2  r   r:  r;  r   r   r   r   r   r)   r-   r-   r-   r.   <module>   s    
 ? 
e 

