Skip to content

Commit

Permalink
Don't automatically switch to lowvram mode on GPUs with low memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed May 17, 2024
1 parent 46daf0a commit 1930065
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions comfy/model_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ def get_total_memory(dev=None, torch_total_too=False):
total_vram = get_total_memory(get_torch_device()) / (1024 * 1024)
total_ram = psutil.virtual_memory().total / (1024 * 1024)
logging.info("Total VRAM {:0.0f} MB, total RAM {:0.0f} MB".format(total_vram, total_ram))
if not args.normalvram and not args.cpu:
if lowvram_available and total_vram <= 4096:
logging.warning("Trying to enable lowvram mode because your GPU seems to have 4GB or less. If you don't want this use: --normalvram")
set_vram_to = VRAMState.LOW_VRAM

try:
OOM_EXCEPTION = torch.cuda.OutOfMemoryError
Expand Down Expand Up @@ -451,9 +447,7 @@ def load_models_gpu(models, memory_required=0, force_patch_weights=False):
model_size = loaded_model.model_memory_required(torch_dev)
current_free_mem = get_free_memory(torch_dev)
lowvram_model_memory = int(max(64 * (1024 * 1024), (current_free_mem - 1024 * (1024 * 1024)) / 1.3 ))
if model_size > (current_free_mem - inference_memory): #only switch to lowvram if really necessary
vram_set_state = VRAMState.LOW_VRAM
else:
if model_size <= (current_free_mem - inference_memory): #only switch to lowvram if really necessary
lowvram_model_memory = 0

if vram_set_state == VRAMState.NO_VRAM:
Expand Down

0 comments on commit 1930065

Please sign in to comment.