Skip to content

Commit 61e105e

Browse files
committed
minor bug fix
1 parent 6c00cff commit 61e105e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

autointent/_embedder.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ def _load_model(self) -> None:
118118

119119
def clear_ram(self) -> None:
120120
"""Move the embedding model to CPU and delete it from memory."""
121-
self._logger.debug("Clearing embedder %s from memory", self.config.model_name)
122-
self.embedding_model.cpu()
123-
del self.embedding_model
124-
torch.cuda.empty_cache()
121+
if hasattr(self, "embedding_model"):
122+
self._logger.debug("Clearing embedder %s from memory", self.config.model_name)
123+
self.embedding_model.cpu()
124+
del self.embedding_model
125+
torch.cuda.empty_cache()
125126

126127
def delete(self) -> None:
127128
"""Delete the embedding model and its associated directory."""

0 commit comments

Comments
 (0)