From fb37628530823ad79baa0120511669205d6eba3b Mon Sep 17 00:00:00 2001 From: Ruibiao Chen Date: Tue, 13 Sep 2022 11:31:23 +0800 Subject: [PATCH] Enable standalone executor for single-GPU training (#45913) * Enable standalone executor for single-GPU training * Disable CompiledProgram._graph * Fix CI errors --- python/paddle/fluid/executor.py | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/python/paddle/fluid/executor.py b/python/paddle/fluid/executor.py index 051d902a27a..39c3468d5fb 100755 --- a/python/paddle/fluid/executor.py +++ b/python/paddle/fluid/executor.py @@ -1555,23 +1555,32 @@ class Executor(object): place, core.CustomPlace): return False - use_standalone_executor_for_compiled_program = os.environ.get( + use_standalone_executor_for_distribution = os.environ.get( 'FLAGS_CONVERT_GRAPH_TO_PROGRAM', None) in [1, '1', True, 'True', 'true'] - # Only support fleet when 'FLAGS_CONVERT_GRAPH_TO_PROGRAM' is set to true - from paddle.distributed.fleet import fleet - if fleet._role_maker is not None and not use_standalone_executor_for_compiled_program: - warnings.warn("Standalone executor is not used for fleet", - UserWarning) - return False - compiled = isinstance(program, compiler.CompiledProgram) or isinstance( program._graph, compiler.CompiledProgram) if compiled: compiled_program = program if isinstance( program, compiler.CompiledProgram) else program._graph + + # delete this code after supporting compiled_program._graph + if compiled_program._program is None: + warnings.warn("Standalone executor is not used for Graph", + UserWarning) + return use_standalone_executor_for_distribution + + # delete this code after supporting distribution + if compiled_program._build_strategy is not None and ( + compiled_program._build_strategy.is_distribution + or compiled_program._build_strategy.num_trainers > 1): + warnings.warn( + "Standalone executor is not used for distribution", + UserWarning) + return use_standalone_executor_for_distribution + # Unsupported case 1: data parallel if compiled_program._is_data_parallel and len( compiled_program._get_places( @@ -1611,10 +1620,14 @@ class Executor(object): UserWarning) return False - return use_standalone_executor_for_compiled_program - else: - assert isinstance(program, Program) - return True + # delete this code after supporting fleet + from paddle.distributed.fleet import fleet + if fleet._role_maker is not None: + warnings.warn("Standalone executor is not used for fleet", + UserWarning) + return use_standalone_executor_for_distribution + + return True # NOTE: This is an experimental feature. If `export FLAGS_USE_STANDALONE_EXECUTOR=1 `, # use StandaloneExecutor to run the program. -- GitLab