get_local_world_size#
- TuneContext.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 >>> from ray import train >>> from ray.train import ScalingConfig >>> from ray.train.torch import TorchTrainer >>> def train_loop_per_worker(): ... print(train.get_context().get_local_world_size()) >>> train_dataset = ray.data.from_items( ... [{"x": x, "y": x + 1} for x in range(32)]) >>> trainer = TorchTrainer(train_loop_per_worker, ... scaling_config=ScalingConfig(num_workers=1), ... datasets={"train": train_dataset}) >>> print("[ignore]"); trainer.fit() [ignore]...
- Returns:
The number of workers running on this node.
- Return type:
PublicAPI (beta): This API is in beta and may change before becoming stable.
Warning
DEPRECATED: This API is deprecated and may be removed in future Ray releases.
get_local_world_sizeis deprecated for Ray Tune because there is no concept of worker ranks for Ray Tune, so these methods only make sense to use in the context of a Ray Train worker. See this issue for more context and migration options: ray-project/ray#49454. Disable these warnings by setting the environment variable: RAY_TRAIN_ENABLE_V2_MIGRATION_WARNINGS=0