Shortcuts

SingleDeviceStrategy

class lightning.pytorch.strategies.SingleDeviceStrategy(device='cpu', accelerator=None, checkpoint_io=None, precision_plugin=None)[소스]

기반 클래스: lightning.pytorch.strategies.strategy.Strategy

Strategy that handles communication on a single device.

all_gather(tensor, group=None, sync_grads=False)[소스]

Perform a all_gather on all processes.

반환 형식

Tensor

barrier(*args, **kwargs)[소스]

Synchronizes all processes which blocks processes until the whole group enters this function.

매개변수

name – an optional name to pass into barrier.

반환 형식

None

broadcast(obj, src=0)[소스]

Broadcasts an object to all processes.

매개변수
  • obj (TypeVar(TBroadcast)) – the object to broadcast

  • src (int) – source rank

반환 형식

TypeVar(TBroadcast)

model_to_device()[소스]

Moves the model to the correct device.

반환 형식

None

reduce(tensor, *args, **kwargs)[소스]

Reduces a tensor from several distributed processes to one aggregated tensor. As this plugin only operates with a single device, the reduction is simply the identity.

매개변수
  • tensor (Union[Any, Tensor]) – the tensor to sync and reduce

  • *args – ignored

  • **kwargs – ignored

반환 형식

Union[Any, Tensor]

반환

the unmodified input as reduction is not needed for single process operation

setup(trainer)[소스]

Setup plugins for the trainer fit and creates optimizers.

매개변수

trainer (Trainer) – the trainer instance

반환 형식

None

property is_global_zero: bool

Whether the current process is the rank zero process not only on the local node, but for all nodes.

반환 형식

bool

property root_device: torch.device

Returns the root device.

반환 형식

device