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

样例:

说明

运行以下样例之前,需要配置好通信环境变量。

针对Ascend/GPU/CPU设备,推荐使用msrun启动方式,无第三方以及配置文件依赖。详见 msrun启动

>>> 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