8000 Fix : Runtime errors by shamitv · Pull Request #1630 · abetlen/llama-cpp-python · GitHub
[go: up one dir, main page]

Skip to content

Fix : Runtime errors #1630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions llama_cpp/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0