balanced offload improvements

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2024-12-01 15:34:25 -05:00
parent 507636d0a1
commit 023b13b6cb
9 changed files with 80 additions and 54 deletions
+15 -3
View File
@@ -5,11 +5,12 @@ from modules import shared, errors
fail_once = False
def gb(val: float):
return round(val / 1024 / 1024 / 1024, 2)
def memory_stats():
global fail_once # pylint: disable=global-statement
def gb(val: float):
return round(val / 1024 / 1024 / 1024, 2)
mem = {}
try:
process = psutil.Process(os.getpid())
@@ -38,3 +39,14 @@ def memory_stats():
except Exception:
pass
return mem
def ram_stats():
try:
process = psutil.Process(os.getpid())
res = process.memory_info()
ram_total = 100 * res.rss / process.memory_percent()
ram = { 'used': gb(res.rss), 'total': gb(ram_total) }
return ram
except Exception:
return { 'used': 0, 'total': 0 }