Skip to content

Commit ef9029d

Browse files
author
chengduo
authored
fix trainer load parameters (#12817)
1 parent fa1feb4 commit ef9029d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

python/paddle/fluid/trainer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,12 @@ def __init__(self,
285285
self._load_checkpoint()
286286

287287
if param_path and os.path.isdir(param_path):
288-
# load params from param_path into scope
289-
io.load_persistables(
290-
executor=exe,
291-
dirname=param_path,
292-
main_program=self.startup_program)
288+
with self._prog_and_scope_guard():
289+
# load params from param_path into scope
290+
io.load_persistables(
291+
executor=exe,
292+
dirname=param_path,
293+
main_program=self.startup_program)
293294

294295
def _transpile_nccl2_dist(self):
295296
# PADDLE_TRAINER_IPS

0 commit comments

Comments
 (0)