Run garbage collection to allow the CUDA cache to completely empty. (#2791)

This commit is contained in:
Jonathan 2023-02-24 07:48:54 -06:00 committed by GitHub
parent 39c57aa358
commit ec2890c19b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -650,6 +650,8 @@ class Generate:
def clear_cuda_cache(self):
if self._has_cuda():
self.gather_cuda_stats()
# Run garbage collection prior to emptying the CUDA cache
gc.collect()
torch.cuda.empty_cache()
def clear_cuda_stats(self):