Make use of suppress_stdout_stderr when freeing model (#803)
This commit is contained in:
parent
a1ac199980
commit
10304d75fc
1 changed files with 8 additions and 1 deletions
|
@ -1655,7 +1655,7 @@ class Llama:
|
|||
)
|
||||
return self._convert_completion_to_chat(completion_or_chunks, stream=stream) # type: ignore
|
||||
|
||||
def __del__(self):
|
||||
def _free_model(self):
|
||||
if hasattr(self, "model") and self.model is not None:
|
||||
llama_cpp.llama_free_model(self.model)
|
||||
self.model = None
|
||||
|
@ -1663,6 +1663,13 @@ class Llama:
|
|||
llama_cpp.llama_free(self.ctx)
|
||||
self.ctx = None
|
||||
|
||||
def __del__(self):
|
||||
if self.verbose:
|
||||
self._free_model()
|
||||
else:
|
||||
with suppress_stdout_stderr():
|
||||
self._free_model()
|
||||
|
||||
def __getstate__(self):
|
||||
return dict(
|
||||
model_path=self.model_path,
|
||||
|
|
Loading…
Reference in a new issue