get_node_rank#

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

Get the rank of this node.

Examples

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

The rank of this node among the nodes participating in training.

Return type:

int