Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORCE_SOFT_EMPTY_CACHE env var to enable cache clearing for AMD GPUs #6115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion comfy/model_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import platform
import weakref
import gc
import os


FORCE_SOFT_EMPTY_CACHE = os.getenv("FORCE_SOFT_EMPTY_CACHE", "0") == "1"


class VRAMState(Enum):
DISABLED = 0 #No vram present: no need to move models to vram
Expand Down Expand Up @@ -1061,7 +1066,7 @@ def supports_fp8_compute(device=None):

return True

def soft_empty_cache(force=False):
def soft_empty_cache(force: bool = FORCE_SOFT_EMPTY_CACHE):
global cpu_state
if cpu_state == CPUState.MPS:
torch.mps.empty_cache()
Expand Down
Loading