Fix bug in model cache reference count checking.

This commit is contained in:
Ryan Dick 2023-11-03 15:21:27 -04:00 committed by Kent Keirsey
parent 8488ab0134
commit fb3d0c4b12

View File

@ -474,11 +474,11 @@ class ModelCache(object):
f" refs: {refs}" f" refs: {refs}"
) )
# 2 refs: # Expected refs:
# 1 from cache_entry # 1 from cache_entry
# 1 from getrefcount function # 1 from getrefcount function
# 1 from onnx runtime object # 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( self.logger.debug(
f"Unloading model {model_key} to free {(model_size/GIG):.2f} GB (-{(cache_entry.size/GIG):.2f} GB)" f"Unloading model {model_key} to free {(model_size/GIG):.2f} GB (-{(cache_entry.size/GIG):.2f} GB)"
) )