MCPcopy Create free account
hub / github.com/OpenRaiser/NanoResearch / unload

Method unload

nanoresearch/evolution/ram.py:417–436  ·  view source on GitHub ↗

Free GPU memory.

(self)

Source from the content-addressed store, hash-verified

415 # ---- cleanup ----------------------------------------------------------
416
417 def unload(self) -> None:
418 """Free GPU memory."""
419 if self._model is not None:
420 del self._model
421 self._model = None
422 if self._tokenizer is not None:
423 del self._tokenizer
424 self._tokenizer = None
425 self._loaded = False
426
427 # Try to free CUDA cache
428 try:
429 import torch
430
431 if torch.cuda.is_available():
432 torch.cuda.empty_cache()
433 except ImportError:
434 pass
435
436 logger.info("RAM: model unloaded")

Callers 1

closeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected