Skip to content

Commit a5e059c

Browse files
committed
Free model when llama is unloaded. Closes #434
1 parent 442213b commit a5e059c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

llama_cpp/llama.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,9 @@ def create_chat_completion(
14371437
return self._convert_text_completion_to_chat(completion)
14381438

14391439
def __del__(self):
1440+
if self.model is not None:
1441+
llama_cpp.llama_free_model(self.model)
1442+
self.model = None
14401443
if self.ctx is not None:
14411444
llama_cpp.llama_free(self.ctx)
14421445
self.ctx = None

0 commit comments

Comments
 (0)