From 501b11de0d2782f1f9e98ac160b5df2ee2927135 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Tue, 12 Jan 2021 10:15:28 +0800 Subject: [PATCH] Delete incorrect warning message (#30196) (#30262) * fix warning and no grad --- python/paddle/hapi/model.py | 4 +++- python/paddle/tests/dist_hapi_mnist_dynamic.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/hapi/model.py b/python/paddle/hapi/model.py index 99e8acd2b0..137ca186d7 100644 --- a/python/paddle/hapi/model.py +++ b/python/paddle/hapi/model.py @@ -621,6 +621,7 @@ class DynamicGraphAdapter(object): self._input_info = None if self._nranks > 1: + dist.init_parallel_env() stradegy = fluid.dygraph.parallel.ParallelStrategy() stradegy.nranks = ParallelEnv().nranks stradegy.local_rank = ParallelEnv().local_rank @@ -888,7 +889,6 @@ class Model(object): # init backend if fluid.in_dygraph_mode(): - dist.init_parallel_env() self._adapter = DynamicGraphAdapter(self) else: self._adapter = StaticGraphAdapter(self) @@ -943,6 +943,7 @@ class Model(object): self._update_inputs() return loss + @paddle.no_grad() def eval_batch(self, inputs, labels=None): """ Run one evaluating step on a batch of data. @@ -994,6 +995,7 @@ class Model(object): self._update_inputs() return loss + @paddle.no_grad() def predict_batch(self, inputs): """ Run one predicting step on a batch of data. diff --git a/python/paddle/tests/dist_hapi_mnist_dynamic.py b/python/paddle/tests/dist_hapi_mnist_dynamic.py index 46d0278940..eab34a6daf 100644 --- a/python/paddle/tests/dist_hapi_mnist_dynamic.py +++ b/python/paddle/tests/dist_hapi_mnist_dynamic.py @@ -61,7 +61,6 @@ class TestDistTraning(unittest.TestCase): def test_static_multiple_gpus(self): device = set_device('gpu') - fluid.enable_dygraph(device) im_shape = (-1, 1, 28, 28) batch_size = 128 -- GitLab