From fb3d0c4b124ecf1e6fb46121f4c8a1ee2cee6cf6 Mon Sep 17 00:00:00 2001 From: Ryan Dick Date: Fri, 3 Nov 2023 15:21:27 -0400 Subject: [PATCH] Fix bug in model cache reference count checking. --- invokeai/backend/model_management/model_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/invokeai/backend/model_management/model_cache.py b/invokeai/backend/model_management/model_cache.py index 2385fd9bec..0b2a8b8df7 100644 --- a/invokeai/backend/model_management/model_cache.py +++ b/invokeai/backend/model_management/model_cache.py @@ -474,11 +474,11 @@ class ModelCache(object): f" refs: {refs}" ) - # 2 refs: + # Expected refs: # 1 from cache_entry # 1 from getrefcount function # 1 from onnx runtime object - if not cache_entry.locked and refs <= 3 if "onnx" in model_key else 2: + if not cache_entry.locked and refs <= (3 if "onnx" in model_key else 2): self.logger.debug( f"Unloading model {model_key} to free {(model_size/GIG):.2f} GB (-{(cache_entry.size/GIG):.2f} GB)" )