mindspore.communication.destroy_group
- mindspore.communication.destroy_group(group)[source]
Destroy the user collective communication group.
Note
This method isn't supported in GPU and CPU versions of MindSpore. The parameter group should not be "hccl_world_group". This method should be used after init().
- Parameters
group (str) – The communication group to destroy, the group should be created by create_group.
- Raises
TypeError – If group is not a string.
ValueError – If group is "hccl_world_group" or backend is invalid.
RuntimeError – If HCCL is not available or MindSpore is GPU/CPU version.
- Supported Platforms:
Ascend
GPU
CPU
Examples
Note
Before running the following examples, you need to configure the communication environment variables.
For Ascend/GPU/CPU 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.
>>> import mindspore as ms >>> from mindspore import set_context >>> from mindspore import ops >>> from mindspore.communication import init, create_group, destroy_group, get_rank >>> set_context(mode=ms.GRAPH_MODE) >>> ms.set_device(device_target="Ascend") >>> init() >>> group = "0-2" >>> rank_ids = [0,2] >>> if get_rank() in rank_ids: ... create_group(group, rank_ids) ... destroy_group(group)