get_local_world_size#

abstractmethod TrainContext.get_local_world_size() → int[source]#

Get the local world size of this node (i.e. number of workers on this node).

Examples

>>> import ray.train
>>> from ray.train.torch import TorchTrainer
>>> def train_fn_per_worker():
...     print(ray.train.get_context().get_local_world_size())
>>> trainer = TorchTrainer(
...     train_fn_per_worker,
...     scaling_config=ray.train.ScalingConfig(num_workers=2),
... )
>>> print("[ignore]"); trainer.fit()
[ignore]...
Returns:

The number of workers running on this node.

Return type:

int