mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-13 04:57:06 +08:00
[feat] upgrade
This commit is contained in:
parent
25a4805e51
commit
5f65c5f8ed
@ -4,6 +4,7 @@ from comfy.cli_args import args
|
|||||||
import comfy.utils
|
import comfy.utils
|
||||||
import torch
|
import torch
|
||||||
import sys
|
import sys
|
||||||
|
import os.path
|
||||||
|
|
||||||
class VRAMState(Enum):
|
class VRAMState(Enum):
|
||||||
DISABLED = 0 #No vram present: no need to move models to vram
|
DISABLED = 0 #No vram present: no need to move models to vram
|
||||||
@ -92,6 +93,11 @@ def get_total_memory(dev=None, torch_total_too=False):
|
|||||||
dev = get_torch_device()
|
dev = get_torch_device()
|
||||||
|
|
||||||
if hasattr(dev, 'type') and (dev.type == 'cpu' or dev.type == 'mps'):
|
if hasattr(dev, 'type') and (dev.type == 'cpu' or dev.type == 'mps'):
|
||||||
|
if os.path.isfile('/sys/fs/cgroup/memory/memory.limit_in_bytes'):
|
||||||
|
with open('/sys/fs/cgroup/memory/memory.limit_in_bytes', 'r') as f:
|
||||||
|
mem_total = int(f.read())
|
||||||
|
mem_total_torch = mem_total
|
||||||
|
else:
|
||||||
mem_total = psutil.virtual_memory().total
|
mem_total = psutil.virtual_memory().total
|
||||||
mem_total_torch = mem_total
|
mem_total_torch = mem_total
|
||||||
else:
|
else:
|
||||||
@ -650,6 +656,13 @@ def get_free_memory(dev=None, torch_free_too=False):
|
|||||||
dev = get_torch_device()
|
dev = get_torch_device()
|
||||||
|
|
||||||
if hasattr(dev, 'type') and (dev.type == 'cpu' or dev.type == 'mps'):
|
if hasattr(dev, 'type') and (dev.type == 'cpu' or dev.type == 'mps'):
|
||||||
|
if os.path.isfile('/sys/fs/cgroup/memory/memory.limit_in_bytes'):
|
||||||
|
with open('/sys/fs/cgroup/memory/memory.limit_in_bytes', 'r') as f:
|
||||||
|
mem_used_total = psutil.virtual_memory().used
|
||||||
|
mem_total = int(f.read())
|
||||||
|
mem_free_total = mem_total - mem_used_total
|
||||||
|
mem_free_torch = mem_free_total
|
||||||
|
else:
|
||||||
mem_free_total = psutil.virtual_memory().available
|
mem_free_total = psutil.virtual_memory().available
|
||||||
mem_free_torch = mem_free_total
|
mem_free_torch = mem_free_total
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user