mindspore.mint.distributed.get_process_group_ranks
- mindspore.mint.distributed.get_process_group_ranks(group=None)[source]
Gets the ranks of the specific group and returns the process ranks in the communication group as a list.
- Parameters
group (str, optional) – The communication group to work on. Normally, the group should be created by
mindspore.mint.distributed.new_group()
. IfNone
, which means"hccl_world_group"
in Ascend. Default:None
.- Returns
List (List[int]), List of process ranks in the specified communication group.
- Raises
TypeError – If the group is not a str.
RuntimeError – If device target is invalid, or backend is invalid, or distributed initialization fails.
- Supported Platforms:
Ascend
Examples
Note
Before running the following examples, you need to configure the communication environment variables.
For Ascend devices, it is recommended to use the msrun startup method without any third-party or configuration file dependencies.
Please see the msrun start up for more details.
This example should be run with 4 devices.
>>> import mindspore as ms >>> from mindspore.mint.distributed import init_process_group, get_process_group_ranks >>> # Launch 4 processes. >>> ms.set_device(device_target="Ascend") >>> init_process_group() >>> output = get_process_group_ranks() >>> print(output) [0, 1, 2, 3]