DDPContextManager#
- class DDPContextManager[source]#
Bases:
AbstractContextManager
Context manager for initializing and destroying DDP process groups.
Note that this context manager does not start processes itself, but merely calls
torch.distributed.init_process_group()
andtorch.distributed.destroy_process_group()
and sets DDP-related fields in theLearner
to appropriate values.If a process group is already initialized, this context manager does nothing on either entry or exit.
- __init__(learner: Learner, rank: int | None = None, world_size: int | None = None) None [source]#
Constructor.
- Parameters:
- Raises:
ValueError – If
rank
orworld_size
not provided and aren’t set on theLearner
.- Return type:
None
Methods
__init__
(learner[, rank, world_size])Constructor.