Skip to content

interlens.loading.model_cache

interlens.loading.model_cache

free

free() -> None

Drop both caches and reclaim GPU memory. Useful between phases that load many models in one process.

Source code in src/interlens/loading/model_cache.py
def free() -> None:
	"""Drop both caches and reclaim GPU memory. Useful between phases that load many models in one process."""
	_WEIGHTS.clear()
	_TOKENIZERS.clear()
	gc.collect()
	if torch.cuda.is_available():
		torch.cuda.empty_cache()