9.2. SYSTEM INFORMATIONΒΆ

import psutil
import platform
import GPUtil
import os
import cpuinfo
un = platform.uname()
print(f"System: {un.system}, Release: {un.release}, Version: {un.version}, Machine: {un.machine}, Processor: {un.processor}")
print(f'Processor model: {platform.processor()}')
print("Physical cores:", psutil.cpu_count(logical=False))
System: Linux, Release: 4.15.0-161-generic, Version: #169-Ubuntu SMP Fri Oct 15 13:41:54 UTC 2021, Machine: x86_64, Processor: x86_64
Processor model: x86_64
Physical cores: 6
info = cpuinfo.get_cpu_info()
for key in ['python_version', 'arch', 'bits', 'count', 'brand_raw', 
            'l1_data_cache_size', 'l1_instruction_cache_size', 'l2_cache_size', 'l3_cache_size']:
    print(f'{key}={info[key]}')
python_version=3.8.3.final.0 (64 bit)
arch=X86_64
bits=64
count=12
brand_raw=Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz
l1_data_cache_size=32768
l1_instruction_cache_size=32768
l2_cache_size=1048576
l3_cache_size=8650752
cpufreq = psutil.cpu_freq()
print(f"Max Frequency: {cpufreq.max:.2f}Mhz")
print(f"Min Frequency: {cpufreq.min:.2f}Mhz")
print(f"Current Frequency: {cpufreq.current:.2f}Mhz")
Max Frequency: 3900.00Mhz
Min Frequency: 1200.00Mhz
Current Frequency: 1735.48Mhz
svmem = psutil.virtual_memory()
print(f"Total: {svmem.total / (2**30)} GB")
print(f"Available: {svmem.available / (2**30):.2f} GB")
Total: 62.60674285888672 GB
Available: 36.83 GB
gpus = GPUtil.getAvailable()
if gpus:
    print(f'Number of GPUs: {len(gpus)}')
    os.system('nvidia-smi')
    from pynvml import *
    nvmlInit()
    print("Driver Version:", nvmlSystemGetDriverVersion())
    deviceCount = nvmlDeviceGetCount()
    for i in range(deviceCount):
        handle = nvmlDeviceGetHandleByIndex(i)
        print("Device", i, ":", nvmlDeviceGetName(handle))
    nvmlShutdown()
Number of GPUs: 1
Wed Dec  1 14:44:03 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.29.05    Driver Version: 495.29.05    CUDA Version: 11.5     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Quadro RTX 5000     Off  | 00000000:17:00.0 Off |                  Off |
| 33%   48C    P8    16W / 230W |    483MiB / 16125MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
|   1  Quadro RTX 5000     Off  | 00000000:65:00.0 Off |                  Off |
| 33%   55C    P2    53W / 230W |   3380MiB / 16122MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      8732      C   ...lesh/anaconda3/bin/python      147MiB |
|    0   N/A  N/A     18800      C   ...lesh/anaconda3/bin/python      209MiB |
|    1   N/A  N/A      8732      C   ...lesh/anaconda3/bin/python      115MiB |
|    1   N/A  N/A     10213      C   /usr/bin/python3                  635MiB |
|    1   N/A  N/A     18800      C   ...lesh/anaconda3/bin/python      115MiB |
+-----------------------------------------------------------------------------+
Driver Version: b'495.29.05'
Device 0 : b'Quadro RTX 5000'
Device 1 : b'Quadro RTX 5000'