diff --git a/paddlenlp/trainer/plugins/timer.py b/paddlenlp/trainer/plugins/timer.py index dc2cf1245800..6413a16eb1b4 100644 --- a/paddlenlp/trainer/plugins/timer.py +++ b/paddlenlp/trainer/plugins/timer.py @@ -32,7 +32,7 @@ def __init__(self, name): def start(self): """Start the timer.""" assert not self.started_, f"{self.name} timer has already started" - if "gpu" in paddle.device.get_device(): + if "cpu" not in paddle.device.get_device(): paddle.device.synchronize() self.start_time = time.time() self.started_ = True @@ -40,7 +40,7 @@ def start(self): def stop(self): """Stop the timers.""" assert self.started_, f"{self.name} timer is not started." - if "gpu" in paddle.device.get_device(): + if "cpu" not in paddle.device.get_device(): paddle.device.synchronize() self.elapsed_ += time.time() - self.start_time self.started_ = False