Commit e5ca9877 authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #11749 from akx/mps-gc-fix-2

Don't do MPS GC when there's a latent
parents 15adff3d 3d524fd3
...@@ -5,7 +5,7 @@ import platform ...@@ -5,7 +5,7 @@ import platform
from modules.sd_hijack_utils import CondFunc from modules.sd_hijack_utils import CondFunc
from packaging import version from packaging import version
log = logging.getLogger() log = logging.getLogger(__name__)
# before torch version 1.13, has_mps is only available in nightly pytorch and macOS 12.3+, # before torch version 1.13, has_mps is only available in nightly pytorch and macOS 12.3+,
...@@ -30,6 +30,10 @@ has_mps = check_for_mps() ...@@ -30,6 +30,10 @@ has_mps = check_for_mps()
def torch_mps_gc() -> None: def torch_mps_gc() -> None:
try: try:
from modules.shared import state
if state.current_latent is not None:
log.debug("`current_latent` is set, skipping MPS garbage collection")
return
from torch.mps import empty_cache from torch.mps import empty_cache
empty_cache() empty_cache()
except Exception: except Exception:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment