mindspore.communication.get_comm_name
- mindspore.communication.get_comm_name(group=GlobalComm.WORLD_COMM_GROUP)[源代码]
获取指定通讯组的通讯器名称。
说明
MindSpore的GPU和CPU版本不支持此方法。
get_comm_name 方法应该在 init 方法之后使用。
- 参数:
group (str) - 传入的通信组名称,通常由 create_group 方法创建,或默认使用
GlobalComm.WORLD_COMM_GROUP
。
- 返回:
str,指定通讯组的通讯器名称。
- 异常:
TypeError - 在参数 group 不是字符串时抛出。
ValueError - 在后端不可用时抛出。
RuntimeError - HCCL 服务不可用时,或者使用了MindSpore的GPU或CPU版本。
- 支持平台:
Ascend
样例:
>>> import mindspore as ms >>> from mindspore.communication import init, create_group, get_rank, get_comm_name >>> ms.set_device(device_target="Ascend") >>> init() >>> world_group_comm_name = get_comm_name() >>> group = "0-7" >>> rank_ids = [0,7] >>> if get_rank() in rank_ids: ... create_group(group, rank_ids) ... customizd_group_comm_name = get_comm_name(group) ... print("comm_name of customizd group is ", customizd_group_comm_name) >>> print("comm_name of world group is: ", world_group_comm_name) comm_name of customizd group is: 11.22.33.44%eth0_60000_0_0123456789101112 comm_name of world group is: 11.22.33.44%eth0_60000_0_1211109876543210