Try to clear more memory at the end of each prompt execution.

This commit is contained in:
comfyanonymous 2023-02-28 11:56:33 -05:00
parent f3103d7b60
commit cd85f876f2
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import json
import threading import threading
import heapq import heapq
import traceback import traceback
import gc
import torch import torch
import nodes import nodes
@ -187,7 +188,10 @@ class PromptExecutor:
if self.server.client_id is not None: if self.server.client_id is not None:
self.server.send_sync("executing", { "node": None }, self.server.client_id) self.server.send_sync("executing", { "node": None }, self.server.client_id)
gc.collect()
torch.cuda.empty_cache() torch.cuda.empty_cache()
torch.cuda.ipc_collect()
def validate_inputs(prompt, item): def validate_inputs(prompt, item):
unique_id = item unique_id = item