mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-23 10:03:36 +08:00
Fix indentation for Docker memory detection
This commit is contained in:
parent
6fdde2271a
commit
8bfa6958de
@ -383,47 +383,47 @@ class RAMPressureCache(LRUCache):
|
|||||||
return super().get(node_id)
|
return super().get(node_id)
|
||||||
|
|
||||||
def poll(self, ram_headroom):
|
def poll(self, ram_headroom):
|
||||||
def _ram_gb():
|
def _ram_gb():
|
||||||
fallback_to_host_available = False
|
fallback_to_host_available = False
|
||||||
cgroup_mem_limit_path = "/sys/fs/cgroup/memory.max"
|
cgroup_mem_limit_path = "/sys/fs/cgroup/memory.max"
|
||||||
cgroup_mem_usage_path = "/sys/fs/cgroup/memory.current"
|
cgroup_mem_usage_path = "/sys/fs/cgroup/memory.current"
|
||||||
|
|
||||||
if not os.path.exists(cgroup_mem_limit_path):
|
if not os.path.exists(cgroup_mem_limit_path):
|
||||||
cgroup_mem_limit_path = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
cgroup_mem_limit_path = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
|
||||||
cgroup_mem_usage_path = "/sys/fs/cgroup/memory/memory.usage_in_bytes"
|
cgroup_mem_usage_path = "/sys/fs/cgroup/memory/memory.usage_in_bytes"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(cgroup_mem_limit_path, "r") as f:
|
with open(cgroup_mem_limit_path, "r") as f:
|
||||||
raw_limit = f.read().strip()
|
raw_limit = f.read().strip()
|
||||||
if raw_limit == "max":
|
if raw_limit == "max":
|
||||||
fallback_to_host_available = True
|
fallback_to_host_available = True
|
||||||
mem_limit = psutil.virtual_memory().total
|
mem_limit = psutil.virtual_memory().total
|
||||||
else:
|
else:
|
||||||
mem_limit = int(raw_limit)
|
mem_limit = int(raw_limit)
|
||||||
if mem_limit == 9223372036854771712:
|
if mem_limit == 9223372036854771712:
|
||||||
fallback_to_host_available = True
|
fallback_to_host_available = True
|
||||||
mem_limit = psutil.virtual_memory().total
|
mem_limit = psutil.virtual_memory().total
|
||||||
except (FileNotFoundError, ValueError):
|
except (FileNotFoundError, ValueError):
|
||||||
fallback_to_host_available = True
|
fallback_to_host_available = True
|
||||||
mem_limit = psutil.virtual_memory().total
|
mem_limit = psutil.virtual_memory().total
|
||||||
|
|
||||||
if fallback_to_host_available:
|
if fallback_to_host_available:
|
||||||
return psutil.virtual_memory().available / (1024**3)
|
return psutil.virtual_memory().available / (1024**3)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(cgroup_mem_usage_path, "r") as f:
|
with open(cgroup_mem_usage_path, "r") as f:
|
||||||
mem_used = int(f.read().strip())
|
mem_used = int(f.read().strip())
|
||||||
except (FileNotFoundError, ValueError):
|
except (FileNotFoundError, ValueError):
|
||||||
mem_used = psutil.virtual_memory().total - psutil.virtual_memory().available
|
mem_used = psutil.virtual_memory().total - psutil.virtual_memory().available
|
||||||
|
|
||||||
mem_available = max(0, mem_limit - mem_used)
|
mem_available = max(0, mem_limit - mem_used)
|
||||||
return mem_available / (1024**3)
|
return mem_available / (1024**3)
|
||||||
|
|
||||||
if _ram_gb() > ram_headroom:
|
if _ram_gb() > ram_headroom:
|
||||||
return
|
return
|
||||||
gc.collect()
|
gc.collect()
|
||||||
if _ram_gb() > ram_headroom:
|
if _ram_gb() > ram_headroom:
|
||||||
return
|
return
|
||||||
|
|
||||||
clean_list = []
|
clean_list = []
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user