src/transformers/trainer_utils.py
def start(self):
        """ start tracking for the caller's stage """
        if self.skip_memory_metrics:
            return

        stage = self.derive_stage()
        # deal with nested calls of eval during train - simply ignore those
        if self.cur_stage is not None and self.cur_stage != stage:
            return

        self.cur_stage = stage

        if self.torch is not None:
            self.torch.cuda.reset_peak_memory_stats()
            self.torch.cuda.empty_cache()

        gc.collect()

        # gpu
        if self.torch is not None:
            self.gpu[self.cur_stage] = {}
            self.gpu[self.cur_stage]["alloc"] = self.torch.cuda.memory_allocated()
            self.gpu[self.cur_stage]["peaked"] = 0

        # cpu
        self.cpu[self.cur_stage] = {}
        tracemalloc.start()
 start tracking for the caller's stage 
start tracking for the caller's stage
start tracking for the caller ' s stage
def start(self):
        if self.skip_memory_metrics:
            return
        stage = self.derive_stage()
        if self.cur_stage is not None and self.cur_stage != stage:
            return
        self.cur_stage = stage
        if self.torch is not None:
            self.torch.cuda.reset_peak_memory_stats()
            self.torch.cuda.empty_cache()
        gc.collect()
        if self.torch is not None:
            self.gpu[self.cur_stage] = {}
            self.gpu[self.cur_stage]["alloc"] = self.torch.cuda.memory_allocated()
            self.gpu[self.cur_stage]["peaked"] = 0
        self.cpu[self.cur_stage] = {}
        tracemalloc.start()
def start ( self ) : if self . skip_memory_metrics : return stage = self . derive_stage ( ) if self . cur_stage is not None and self . cur_stage != stage : return self . cur_stage = stage if self . torch is not None : self . torch . cuda . reset_peak_memory_stats ( ) self . torch . cuda . empty_cache ( ) gc . collect ( ) if self . torch is not None : self . gpu [ self . cur_stage ] = { } self . gpu [ self . cur_stage ] [ "alloc" ] = self . torch . cuda . memory_allocated ( ) self . gpu [ self . cur_stage ] [ "peaked" ] = 0 self . cpu [ self . cur_stage ] = { } tracemalloc . start ( )
start tracking for the caller's stage
start tracking for the caller ' s stage
""" start tracking for the caller's stage """ # deal with nested calls of eval during train - simply ignore those # gpu # cpu
self