From ab1ab07ab3b8f0b8d857518c9ea56507390d1c18 Mon Sep 17 00:00:00 2001 From: shamitv Date: Sun, 28 Jul 2024 16:23:21 +0000 Subject: [PATCH] Fix : Runtime errors --- llama_cpp/llama.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/llama_cpp/llama.py b/llama_cpp/llama.py index 005045f5c..0cb5ca2fc 100644 --- a/llama_cpp/llama.py +++ b/llama_cpp/llama.py @@ -2083,11 +2083,14 @@ def pooling_type(self) -> str: def close(self) -> None: """Explicitly free the model from memory.""" - self._stack.close() + if hasattr(self,'_stack'): + if self._stack is not None: + self._stack.close() def __del__(self) -> None: - if self._lora_adapter is not None: - llama_cpp.llama_lora_adapter_free(self._lora_adapter) + if hasattr(self,'_lora_adapter'): + if self._lora_adapter is not None: + llama_cpp.llama_lora_adapter_free(self._lora_adapter) self.close() @staticmethod