sysinfo handle psutil not working

This commit is contained in:
w-e-w 2024-07-08 15:45:45 +09:00
parent bad47dcfeb
commit 7d7f7f4b49

View File

@ -5,7 +5,6 @@ import sys
import platform import platform
import hashlib import hashlib
import pkg_resources import pkg_resources
import psutil
import re import re
import launch import launch
@ -69,9 +68,27 @@ def check(x):
return h.hexdigest() == m.group(1) return h.hexdigest() == m.group(1)
def get_dict(): def get_cpu_info():
ram = psutil.virtual_memory() cpu_info = {"model": platform.processor()}
try:
import psutil
cpu_info["count logical"] = psutil.cpu_count(logical=True)
cpu_info["count physical"] = psutil.cpu_count(logical=False)
except Exception as e:
cpu_info["error"] = str(e)
return cpu_info
def get_ram_info():
try:
import psutil
ram = psutil.virtual_memory()
return {x: pretty_bytes(getattr(ram, x, 0)) for x in ["total", "used", "free", "active", "inactive", "buffers", "cached", "shared"] if getattr(ram, x, 0) != 0}
except Exception as e:
return str(e)
def get_dict():
res = { res = {
"Platform": platform.platform(), "Platform": platform.platform(),
"Python": platform.python_version(), "Python": platform.python_version(),
@ -84,14 +101,8 @@ def get_dict():
"Commandline": get_argv(), "Commandline": get_argv(),
"Torch env info": get_torch_sysinfo(), "Torch env info": get_torch_sysinfo(),
"Exceptions": errors.get_exceptions(), "Exceptions": errors.get_exceptions(),
"CPU": { "CPU": get_cpu_info(),
"model": platform.processor(), "RAM": get_ram_info(),
"count logical": psutil.cpu_count(logical=True),
"count physical": psutil.cpu_count(logical=False),
},
"RAM": {
x: pretty_bytes(getattr(ram, x, 0)) for x in ["total", "used", "free", "active", "inactive", "buffers", "cached", "shared"] if getattr(ram, x, 0) != 0
},
"Extensions": get_extensions(enabled=True), "Extensions": get_extensions(enabled=True),
"Inactive extensions": get_extensions(enabled=False), "Inactive extensions": get_extensions(enabled=False),
"Environment": get_environment(), "Environment": get_environment(),
@ -123,6 +134,7 @@ def get_argv():
return res return res
re_newline = re.compile(r"\r*\n") re_newline = re.compile(r"\r*\n")