Free model when llama is unloaded. Closes #434

This commit is contained in:
Andrei Betlen 2023-06-28 23:58:55 -04:00
parent 442213b070
commit a5e059c053

View file

@ -1437,6 +1437,9 @@ class Llama:
return self._convert_text_completion_to_chat(completion)
def __del__(self):
if self.model is not None:
llama_cpp.llama_free_model(self.model)
self.model = None
if self.ctx is not None:
llama_cpp.llama_free(self.ctx)
self.ctx = None