MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / init

Method init

python/paddle/distributed/fleet/fleet.py:220–418  ·  view source on GitHub ↗

Initialize role_maker in Fleet. This function is responsible for the distributed architecture what you want to run your code behind. Args: role_maker (RoleMakerBase, optional): A ``RoleMakerBase`` containing the configuration of environm

(
        self,
        role_maker: RoleMakerBase | None = None,
        is_collective: bool = False,
        strategy: DistributedStrategy | None = None,
        log_level: int | str = "INFO",
    )

Source from the content-addressed store, hash-verified

218 self.user_defined_optimizer: Optimizer = paddle.optimizer.Optimizer(0.0)
219
220 def init(
221 self,
222 role_maker: RoleMakerBase | None = None,
223 is_collective: bool = False,
224 strategy: DistributedStrategy | None = None,
225 log_level: int | str = "INFO",
226 ) -> Self:
227 """
228 Initialize role_maker in Fleet.
229
230 This function is responsible for the distributed architecture
231 what you want to run your code behind.
232
233 Args:
234 role_maker (RoleMakerBase, optional): A ``RoleMakerBase`` containing the configuration
235 of environment variables related to distributed training.If you did not initialize
236 the rolemaker by yourself, it will be automatically initialized to PaddleRoleMaker.
237 The default value is None.
238 is_collective (Boolean, optional): A ``Boolean`` variable determines whether the program
239 runs on Collective mode or ParameterServer mode. True means the program runs on
240 Collective mode, and False means running on ParameterServer mode. The default value
241 is False.
242 strategy (DistributedStrategy): Extra properties for distributed training.
243 For details, please refer to paddle.distributed.fleet.DistributedStrategy. Default: None.
244 log_level (Integer, String, optional): A ``Integer`` or ``String`` Variable determining how height
245 the logging level is. Default is "INFO".
246
247 Returns:
248 None
249
250 Examples:
251 .. code-block:: pycon
252 :name: code-init-example1
253
254 >>> import paddle.distributed.fleet as fleet
255 >>> fleet.init()
256
257 .. code-block:: pycon
258 :name: code-init-example2
259
260 >>> import paddle.distributed.fleet as fleet
261 >>> fleet.init(is_collective=True)
262
263 .. code-block:: pycon
264 :name: code-init-example3
265
266 >>> import paddle.distributed.fleet as fleet
267 >>> role = fleet.PaddleCloudRoleMaker()
268 >>> fleet.init(role)
269
270 .. code-block:: pycon
271 :name: code-init-example4
272
273 >>> import paddle.distributed.fleet as fleet
274 >>> strategy = fleet.DistributedStrategy()
275 >>> fleet.init(strategy=strategy)
276
277 .. code-block:: pycon

Callers 7

runMethod · 0.45
_make_programMethod · 0.45
init_parallel_envFunction · 0.45
_init_parallel_ctxFunction · 0.45
gloo_init_parallel_envFunction · 0.45
launchFunction · 0.45
train_resnetFunction · 0.45

Calls 15

worker_indexMethod · 0.95
worker_numMethod · 0.95
set_log_levelFunction · 0.85
ValueErrorClass · 0.85
StrategyCompilerClass · 0.85
strFunction · 0.85
listFunction · 0.85
rangeFunction · 0.85
_set_role_makerMethod · 0.80
set_comm_groupMethod · 0.80
DistributedStrategyClass · 0.50

Tested by 1

train_resnetFunction · 0.36