Spaces:
Paused
Paused
clean resources properly
Browse files- generate_multitalk.py +8 -0
generate_multitalk.py
CHANGED
|
@@ -6,6 +6,7 @@ import sys
|
|
| 6 |
import json
|
| 7 |
import warnings
|
| 8 |
from datetime import datetime
|
|
|
|
| 9 |
|
| 10 |
warnings.filterwarnings('ignore')
|
| 11 |
|
|
@@ -494,6 +495,13 @@ def generate(args):
|
|
| 494 |
|
| 495 |
logging.info("Finished.")
|
| 496 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
|
| 498 |
if __name__ == "__main__":
|
| 499 |
args = _parse_args()
|
|
|
|
| 6 |
import json
|
| 7 |
import warnings
|
| 8 |
from datetime import datetime
|
| 9 |
+
import gc
|
| 10 |
|
| 11 |
warnings.filterwarnings('ignore')
|
| 12 |
|
|
|
|
| 495 |
|
| 496 |
logging.info("Finished.")
|
| 497 |
|
| 498 |
+
if torch.cuda.is_available():
|
| 499 |
+
torch.cuda.empty_cache()
|
| 500 |
+
torch.cuda.ipc_collect() # optional but useful with multiprocessing
|
| 501 |
+
gc.collect()
|
| 502 |
+
|
| 503 |
+
if dist.is_initialized():
|
| 504 |
+
dist.destroy_process_group()
|
| 505 |
|
| 506 |
if __name__ == "__main__":
|
| 507 |
args = _parse_args()
|