From a12df985879323b43dd051222b0d00692292e682 Mon Sep 17 00:00:00 2001 From: liyurui Date: Mon, 10 Jan 2022 16:46:32 +0800 Subject: [PATCH] minor fix --- python/paddle/fluid/executor.py | 26 +++++-------------- .../tests/unittests/test_fleet_executor.py | 2 -- .../test_fleet_executor_origin_scheduler.py | 2 -- .../test_fleet_executor_with_task_nodes.py | 2 -- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 70b74d1032d73..82259ad5b86d6 100644 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -400,17 +400,6 @@ def _is_enable_standalone_executor(): return flag -def _is_enable_fleet_executor(): - """ - Whether to use experimental executor `FleetExecutor`. - """ - flag = False - env_val = os.environ.get('FLAGS_USE_FLEET_EXECUTOR', None) - if env_val in [1, '1', True, 'True', 'true']: - flag = True - return flag - - def _prepare_fleet_executor(): from ..distributed.fleet.proto import fleet_executor_desc_pb2 trainer_endpoints_str = os.getenv("PADDLE_TRAINER_ENDPOINTS", "") @@ -720,8 +709,6 @@ def __init__(self, place=None): self._enable_interpreter_core = _is_enable_standalone_executor() self._executor_cache = _ExecutorCache(self.place) - # NOTE: Whether to use experimental executor `FleetExecutor`. - self._enable_fleet_executor = _is_enable_fleet_executor() self._fleet_executor = None def _get_scope_cache(self, program_cache_key): @@ -1311,14 +1298,13 @@ def _run_impl(self, program, feed, fetch_list, feed_var_name, fetch_list = self._check_fetch_list(fetch_list) - if self._enable_fleet_executor: - # Move prepare here for port conflict with nccl in startup program - if self._fleet_executor is None: - self._fleet_executor = _prepare_fleet_executor() - return self._run_using_fleet_executor( - program=program, feed=feed, fetch_list=fetch_list) - if isinstance(program, Program) and program._pipeline_opt: + if "fleet_opt" in program._pipeline_opt: + # Move prepare here for port conflict with nccl in startup program + if self._fleet_executor is None: + self._fleet_executor = _prepare_fleet_executor() + return self._run_using_fleet_executor( + program=program, feed=feed, fetch_list=fetch_list) if "startup_program" in program._pipeline_opt: program = program._pipeline_opt["startup_program"] else: diff --git a/python/paddle/fluid/tests/unittests/test_fleet_executor.py b/python/paddle/fluid/tests/unittests/test_fleet_executor.py index cafc269061119..8b73a714bbbc5 100644 --- a/python/paddle/fluid/tests/unittests/test_fleet_executor.py +++ b/python/paddle/fluid/tests/unittests/test_fleet_executor.py @@ -13,7 +13,6 @@ # limitations under the License. import unittest -import os import numpy as np import paddle import paddle.fluid as fluid @@ -73,7 +72,6 @@ def run_fleet_executor(self, place, x_data, y_data): return res def test_executor_on_single_device(self): - os.environ["FLAGS_USE_FLEET_EXECUTOR"] = "1" if fluid.is_compiled_with_cuda(): shape = (10000, 3462) x_data = np.random.rand(*shape) diff --git a/python/paddle/fluid/tests/unittests/test_fleet_executor_origin_scheduler.py b/python/paddle/fluid/tests/unittests/test_fleet_executor_origin_scheduler.py index bdb7902617ce0..4bbb3bff07f97 100644 --- a/python/paddle/fluid/tests/unittests/test_fleet_executor_origin_scheduler.py +++ b/python/paddle/fluid/tests/unittests/test_fleet_executor_origin_scheduler.py @@ -13,7 +13,6 @@ # limitations under the License. import unittest -import os import numpy as np import paddle import paddle.fluid as fluid @@ -73,7 +72,6 @@ def run_fleet_executor(self, place, x_data, y_data): return res def test_executor_on_single_device(self): - os.environ["FLAGS_USE_FLEET_EXECUTOR"] = "1" if fluid.is_compiled_with_cuda(): shape = (10000, 3462) x_data = np.random.rand(*shape) diff --git a/python/paddle/fluid/tests/unittests/test_fleet_executor_with_task_nodes.py b/python/paddle/fluid/tests/unittests/test_fleet_executor_with_task_nodes.py index 222b7f0b52c56..61064175266bb 100644 --- a/python/paddle/fluid/tests/unittests/test_fleet_executor_with_task_nodes.py +++ b/python/paddle/fluid/tests/unittests/test_fleet_executor_with_task_nodes.py @@ -13,7 +13,6 @@ # limitations under the License. import unittest -import os import numpy as np import paddle import paddle.fluid as fluid @@ -68,7 +67,6 @@ def run_fleet_executor(self, place, x_data, y_data): return res def test_executor_on_single_device(self): - os.environ["FLAGS_USE_FLEET_EXECUTOR"] = "1" if fluid.is_compiled_with_cuda(): shape = (10000, 3462) x_data = np.random.rand(*shape)