Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 10304d7

Browse filesBrowse files
authored
Make use of suppress_stdout_stderr when freeing model (abetlen#803)
1 parent a1ac199 commit 10304d7
Copy full SHA for 10304d7

File tree

Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed

‎llama_cpp/llama.py

Copy file name to clipboardExpand all lines: llama_cpp/llama.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,14 +1655,21 @@ def create_chat_completion(
16551655
)
16561656
return self._convert_completion_to_chat(completion_or_chunks, stream=stream) # type: ignore
16571657

1658-
def __del__(self):
1658+
def _free_model(self):
16591659
if hasattr(self, "model") and self.model is not None:
16601660
llama_cpp.llama_free_model(self.model)
16611661
self.model = None
16621662
if hasattr(self, "ctx") and self.ctx is not None:
16631663
llama_cpp.llama_free(self.ctx)
16641664
self.ctx = None
16651665

1666+
def __del__(self):
1667+
if self.verbose:
1668+
self._free_model()
1669+
else:
1670+
with suppress_stdout_stderr():
1671+
self._free_model()
1672+
16661673
def __getstate__(self):
16671674
return dict(
16681675
model_path=self.model_path,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.