mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-02 10:47:07 +08:00
Merge 0e0f1ed5bc760bd8316e7094c6e06910aaef83e1 into 255f1398638b265a47d0e74fb4759fe6cfc3b3d4
This commit is contained in:
commit
e02da70477
@ -131,6 +131,13 @@ parser.add_argument("--reserve-vram", type=float, default=None, help="Set the am
|
|||||||
|
|
||||||
parser.add_argument("--async-offload", action="store_true", help="Use async weight offloading.")
|
parser.add_argument("--async-offload", action="store_true", help="Use async weight offloading.")
|
||||||
|
|
||||||
|
class CpuBf16Mode(enum.Enum):
|
||||||
|
Auto = "auto"
|
||||||
|
Yes = "yes"
|
||||||
|
No = "no"
|
||||||
|
|
||||||
|
parser.add_argument("--use-cpu-bf16", type=CpuBf16Mode, default=CpuBf16Mode.Auto, help="When CPU mode is enabled use bf16 instructions to improve performance.", action=EnumAction)
|
||||||
|
|
||||||
parser.add_argument("--default-hashing-function", type=str, choices=['md5', 'sha1', 'sha256', 'sha512'], default='sha256', help="Allows you to choose the hash function to use for duplicate filename / contents comparison. Default is sha256.")
|
parser.add_argument("--default-hashing-function", type=str, choices=['md5', 'sha1', 'sha256', 'sha512'], default='sha256', help="Allows you to choose the hash function to use for duplicate filename / contents comparison. Default is sha256.")
|
||||||
|
|
||||||
parser.add_argument("--disable-smart-memory", action="store_true", help="Force ComfyUI to agressively offload to regular ram instead of keeping models in vram when it can.")
|
parser.add_argument("--disable-smart-memory", action="store_true", help="Force ComfyUI to agressively offload to regular ram instead of keeping models in vram when it can.")
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
import psutil
|
import psutil
|
||||||
import logging
|
import logging
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from comfy.cli_args import args, PerformanceFeature
|
from comfy.cli_args import args, PerformanceFeature, CpuBf16Mode
|
||||||
import torch
|
import torch
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
@ -151,6 +151,21 @@ def is_mlu():
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def use_cpu_bf16():
|
||||||
|
if args.use_cpu_bf16 == CpuBf16Mode.No or cpu_state != CPUState.CPU:
|
||||||
|
return False
|
||||||
|
if args.use_cpu_bf16 == CpuBf16Mode.Yes:
|
||||||
|
return True
|
||||||
|
|
||||||
|
try:
|
||||||
|
from cpuinfo import get_cpu_info
|
||||||
|
except:
|
||||||
|
logging.warning('py-cpuinfo is not installed, rerun "pip install -r requirements.txt"')
|
||||||
|
return False
|
||||||
|
|
||||||
|
cpu_info = get_cpu_info()
|
||||||
|
return 'avx512_bf16' in cpu_info['flags']
|
||||||
|
|
||||||
def get_torch_device():
|
def get_torch_device():
|
||||||
global directml_enabled
|
global directml_enabled
|
||||||
global cpu_state
|
global cpu_state
|
||||||
@ -1244,8 +1259,8 @@ def should_use_fp16(device=None, model_params=0, prioritize_performance=True, ma
|
|||||||
|
|
||||||
def should_use_bf16(device=None, model_params=0, prioritize_performance=True, manual_cast=False):
|
def should_use_bf16(device=None, model_params=0, prioritize_performance=True, manual_cast=False):
|
||||||
if device is not None:
|
if device is not None:
|
||||||
if is_device_cpu(device): #TODO ? bf16 works on CPU but is extremely slow
|
if is_device_cpu(device):
|
||||||
return False
|
return use_cpu_bf16()
|
||||||
|
|
||||||
if FORCE_FP32:
|
if FORCE_FP32:
|
||||||
return False
|
return False
|
||||||
@ -1259,7 +1274,7 @@ def should_use_bf16(device=None, model_params=0, prioritize_performance=True, ma
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if cpu_mode():
|
if cpu_mode():
|
||||||
return False
|
return use_cpu_bf16()
|
||||||
|
|
||||||
if is_intel_xpu():
|
if is_intel_xpu():
|
||||||
if torch_version_numeric < (2, 6):
|
if torch_version_numeric < (2, 6):
|
||||||
|
|||||||
@ -18,6 +18,7 @@ Pillow
|
|||||||
scipy
|
scipy
|
||||||
tqdm
|
tqdm
|
||||||
psutil
|
psutil
|
||||||
|
py-cpuinfo
|
||||||
alembic
|
alembic
|
||||||
SQLAlchemy
|
SQLAlchemy
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user