hooks.py 211 Bytes
Newer Older
Kai Chen's avatar
Kai Chen committed
1
import torch
Kai Chen's avatar
Kai Chen committed
2
from mmcv.runner import Hook
pangjm's avatar
pangjm committed
3

Kai Chen's avatar
Kai Chen committed
4
5
6
7
8
9
10
11

class EmptyCacheHook(Hook):

    def before_epoch(self, runner):
        torch.cuda.empty_cache()

    def after_epoch(self, runner):
        torch.cuda.empty_cache()