Skip to content

Commit b6bc4cb

Browse files
authored
support dp run single card (#29358) (#29372)
1 parent 374822b commit b6bc4cb

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

python/paddle/distributed/fleet/base/fleet_base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ def init(self, role_maker=None, is_collective=False, strategy=None):
179179
fleet.init(strategy=strategy)
180180
181181
"""
182+
if strategy is None:
183+
strategy = DistributedStrategy()
184+
self._user_defined_strategy = copy.deepcopy(strategy)
182185

183186
if role_maker is None:
184187
if isinstance(is_collective, bool):
@@ -220,10 +223,6 @@ def init(self, role_maker=None, is_collective=False, strategy=None):
220223
else:
221224
paddle.distributed.init_parallel_env()
222225

223-
if strategy is None:
224-
strategy = DistributedStrategy()
225-
self._user_defined_strategy = copy.deepcopy(strategy)
226-
227226
def is_first_worker(self):
228227
"""
229228
Check whether the node is the first instance of worker.

python/paddle/fluid/dygraph/parallel.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,10 @@ def __init__(self,
395395
1024)
396396
self.init_reducer()
397397
else:
398-
warnings.warn(
399-
"nranks is less than 2, "
400-
"maybe you need to check the current system environment."
401-
" Need to use spawn or fleetrun to "
402-
"start distributed programs.")
398+
warnings.warn("The program will return to single-card operation. "
399+
"Please check 1, whether you use spawn or fleetrun "
400+
"to start the program. 2. Whether it is a multi-card "
401+
"program. 3. Is the current environment multi-card.")
403402

404403
def init_reducer(self):
405404
layers_param = []

0 commit comments

Comments
 (0)