Call garbage collector after unload model

This commit is contained in:
David Bejar Caceres 2022-12-16 16:27:18 +01:00
parent 0c4de4776e
commit e5acbc6be9

View File

@ -46,8 +46,8 @@ class ModelManager:
if (torch.cuda.memory_allocated() > 0): if (torch.cuda.memory_allocated() > 0):
# Clear current loaded model from memory # Clear current loaded model from memory
torch.cuda.empty_cache() torch.cuda.empty_cache()
gc.collect()
del self.model del self.model
gc.collect()
self.model = self.init_model(new_name, self.device, **self.kwargs) self.model = self.init_model(new_name, self.device, **self.kwargs)
self.name = new_name self.name = new_name