From f8d0d84f7e232da8efdf97eb1dccc79679ee7c18 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Wed, 28 Feb 2018 17:09:04 +0800 Subject: [PATCH] fix multi card --- python/paddle/fluid/backward.py | 3 +++ python/paddle/fluid/layers/control_flow.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/backward.py b/python/paddle/fluid/backward.py index 58fa7f1beb..e02245d05d 100644 --- a/python/paddle/fluid/backward.py +++ b/python/paddle/fluid/backward.py @@ -220,7 +220,10 @@ def _callback_lookup_(op): :return: callback function """ if op.type == 'parallel_do' and op.attr('use_nccl'): + all_vars = op.block.vars param_names = set(op.input('parameters')) + param_names = filter(lambda name: all_vars[name].stop_gradient is False, + param_names) param_grad_names = [n + "@GRAD" for n in param_names] class ParallelDoCallBack(object): diff --git a/python/paddle/fluid/layers/control_flow.py b/python/paddle/fluid/layers/control_flow.py index ff88618563..1bb1aa30ee 100644 --- a/python/paddle/fluid/layers/control_flow.py +++ b/python/paddle/fluid/layers/control_flow.py @@ -294,8 +294,7 @@ class ParallelDo(object): params = list(set(params)) - param_list = [parent_block.var(name) for name in params] - return filter(lambda param: param.stop_gradient is False, param_list) + return [parent_block.var(name) for name in params] def complete_op(self): main_program = self.helper.main_program -- GitLab