add clear cache when batch is finished

This commit is contained in:
OlivierDehaene 2023-07-19 01:12:28 +02:00
parent 0111869ad0
commit 8793ae5890
2 changed files with 3 additions and 0 deletions

View File

@ -349,6 +349,7 @@ async fn batching_task(
} }
metrics::gauge!("tgi_batch_current_size", 0.0); metrics::gauge!("tgi_batch_current_size", 0.0);
metrics::gauge!("tgi_batch_current_max_tokens", 0.0); metrics::gauge!("tgi_batch_current_max_tokens", 0.0);
let _ = client.clear_cache(None).await;
} }
} }
} }

View File

@ -29,6 +29,8 @@ class Cache:
keys = list(self.cache.keys()) keys = list(self.cache.keys())
for k in keys: for k in keys:
self.delete(k) self.delete(k)
if torch.cuda.is_available():
torch.cuda.empty_cache()
def __len__(self): def __len__(self):
return len(self.cache.keys()) return len(self.cache.keys())