src/transformers/trainer_utils.py
def update_metrics(self, stage, metrics):
        """ stop tracking for the passed stage """
        if self.skip_memory_metrics:
            return

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

        # since we don't have a way to return init metrics, we push them into the first of train/val/predict
        stages = [stage]
        if not self.init_reported:
            stages.insert(0, "init")
            self.init_reported = True

        for stage in stages:
            for t in ["alloc", "peaked"]:
                if stage in self.cpu and t in self.cpu[stage]:
                    metrics[f"{stage}_mem_cpu_{t}_delta"] = self.cpu[stage][t]
                if self.torch is not None and stage in self.gpu and t in self.gpu[stage]:
                    metrics[f"{stage}_mem_gpu_{t}_delta"] = self.gpu[stage][t]
 stop tracking for the passed stage 
stop tracking for the passed stage
stop tracking for the passed stage
def update_metrics(self, stage, metrics):
        if self.skip_memory_metrics:
            return
        if self.cur_stage is not None and self.cur_stage != stage:
            return
        stages = [stage]
        if not self.init_reported:
            stages.insert(0, "init")
            self.init_reported = True
        for stage in stages:
            for t in ["alloc", "peaked"]:
                if stage in self.cpu and t in self.cpu[stage]:
                    metrics[f"{stage}_mem_cpu_{t}_delta"] = self.cpu[stage][t]
                if self.torch is not None and stage in self.gpu and t in self.gpu[stage]:
                    metrics[f"{stage}_mem_gpu_{t}_delta"] = self.gpu[stage][t]
def update_metrics ( self , stage , metrics ) : if self . skip_memory_metrics : return if self . cur_stage is not None and self . cur_stage != stage : return stages = [ stage ] if not self . init_reported : stages . insert ( 0 , "init" ) self . init_reported = True for stage in stages : for t in [ "alloc" , "peaked" ] : if stage in self . cpu and t in self . cpu [ stage ] : metrics [ f"{stage}_mem_cpu_{t}_delta" ] = self . cpu [ stage ] [ t ] if self . torch is not None and stage in self . gpu and t in self . gpu [ stage ] : metrics [ f"{stage}_mem_gpu_{t}_delta" ] = self . gpu [ stage ] [ t ]
stop tracking for the passed stage
stop tracking for the passed stage
""" stop tracking for the passed stage """ # deal with nested calls of eval during train - simply ignore those # since we don't have a way to return init metrics, we push them into the first of train/val/predict
self
stage
metrics