DDPStrategy
- class lightning.fabric.strategies.DDPStrategy(accelerator=None, parallel_devices=None, cluster_environment=None, checkpoint_io=None, precision=None, process_group_backend=None, timeout=datetime.timedelta(seconds=1800), start_method='popen', **kwargs)
Bases:
ParallelStrategyStrategy for multi-process single-device training on one or multiple nodes.
- _configure_launcher()
Attach the launcher based on Strategy.
- Return type:
- all_reduce(tensor, group=None, reduce_op='mean')
Reduces a tensor from several distributed processes to one aggregated tensor.
- Parameters:
tensor (
Tensor) – the tensor to sync and reducegroup (
Optional[Any]) – the process group to gather results from. Defaults to all processes (world)reduce_op (
Union[ReduceOp,str,None]) – the reduction operation. Defaults to ‘mean’/’avg’. Can also be a string ‘sum’ to calculate the sum during reduction.
- Return type:
- Returns:
reduced value, except when the input was not a tensor the output remains is unchanged
- barrier(*args, **kwargs)
Synchronizes all processes which blocks processes until the whole group enters this function.
- Parameters:
name – an optional name to pass into barrier.
- Return type:
- broadcast(obj, src=0)
Broadcasts an object to all processes.
- load_module_state_dict(module, state_dict, strict=True)
Loads the given state into the model.
- Return type:
- module_to_device(module)
Moves the model to the correct device.
- Return type:
- setup_environment()
Setup any processes or distributed connections.
This must be called by the framework at the beginning of every process, before any distributed communication takes place.
- Return type:
- setup_module(module)
Wraps the model into a
DistributedDataParallelmodule.- Return type:
- property distributed_sampler_kwargs: dict[str, Any]
Arguments for the
DistributedSampler.If this method is not defined, or it returns
None, then theDistributedSamplerwill not be used.
- property root_device: device
Returns the root device.
Was this page helpful?
Thanks for the feedback.