clean_memory.py 211 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
# Copyright (c) Opendatalab. All rights reserved.
import torch
import gc


def clean_memory():
    if torch.cuda.is_available():
        torch.cuda.empty_cache()
        torch.cuda.ipc_collect()
    gc.collect()