hooks.py 214 Bytes
Newer Older
Kai Chen's avatar
Kai Chen committed
1
2
import torch
from mmcv.torchpack 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()