CANN/HCOMM通信器初始化示例

CANN/HCOMM通信器初始化示例
Communicator Management - One NPU Device per Process (Initialize Communicator Based on Rank Table)【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcommSample OverviewThis sample demonstrates how to use theHcclCommInitClusterInfoConfig()API to initialize a communicator based on therank_table.jsonconfiguration file. It covers the following features:Launch multiple processes through MPI. Each process reads therank_table.jsonfile and initializes the communicator using theHcclCommInitClusterInfoConfig()API.Call theHcclAllReduce()operator and print the results.Directory Structure├── main.cc # Sample source file ├── Makefile # Build or configuration file ├── rank_table.json # Cluster information configuration file └── one_device_per_process_rank_table # Compiled executableEnvironment PreparationRequirementsThis sample supports the following products with a single-node 2-card cluster topology:Ascend 950PR / Ascend 950DTThis sample supports the following products with a single-node 8-card cluster topology:Atlas A3 training series products / Atlas A3 inference series productsAtlas A2 training series productsAtlas training series products / Atlas inference series productsSoftware DependenciesRunning this sample requires the CANN ops operator package to be installed. For detailed installation steps, see the Install the CANN Software Package section in Source Code Build.Installing MPIThis sample depends on MPI to launch processes on each Device. Before running this sample, install MPI. For detailed installation steps, see the MPI Installation and Configuration section in the corresponding version of the HCCL Performance Test Tool User Guide.Disabling Signature VerificationThecann-hcomm_version_linux-arch.runsoftware package generated from this source repository contains the following tar.gz subpackages:cann-hcomm-compat.tar.gz: HCOMM compatibility upgrade package.cann-hccd-compat.tar.gz: DataFlow compatibility upgrade package.aicpu_hcomm.tar.gz: AI CPU communication base package.These tar.gz packages are loaded to the Device when the service starts. During the loading process, the driver performs security signature verification by default to ensure the package is trusted. Because the tar.gz packages compiled from this source repository do not contain a signature header, the driver security signature verification mechanism needs to be disabled. For the method to disable signature verification, refer to the Disable Signature Verification section in Source Code Build.Configuring Environment Variables# Set CANN environment variables, using the root user default installation path as an example source /usr/local/Ascend/cann/set_env.sh # Set the MPI installation directory. Adjust it based on the actual situation. export MPI_HOME/usr/local/mpichCompiling and Running the SampleExecute the following commands in the sample code directory:make make test N${RANK_SIZE}RANK_SIZEis the number of cluster devices. For the Ascend 950PR and Ascend 950DT product series,RANK_SIZEis 2. For other product series, it is 8.Note: You can set theHCCL_OP_EXPANSION_MODEenvironment variable to configure the expansion mode of communication operators. For the range supported by different product models, refer to the usage of this environment variable in the Environment Variable List.# Set the expansion mode of communication operators to AI CPU communication engine export HCCL_OP_EXPANSION_MODEAI_CPUSample OutputThe data for each rank is initialized to 0 to 7. After the AllReduce operation, the result for each rank is the sum of the data at the corresponding positions across all ranks (the data from 8 ranks is summed).Found 8 NPU device(s) available rankId: 0, output: [ 0 8 16 24 32 40 48 56 ] rankId: 1, output: [ 0 8 16 24 32 40 48 56 ] rankId: 2, output: [ 0 8 16 24 32 40 48 56 ] rankId: 3, output: [ 0 8 16 24 32 40 48 56 ] rankId: 4, output: [ 0 8 16 24 32 40 48 56 ] rankId: 5, output: [ 0 8 16 24 32 40 48 56 ] rankId: 6, output: [ 0 8 16 24 32 40 48 56 ] rankId: 7, output: [ 0 8 16 24 32 40 48 56 ]【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

最新新闻

日新闻

周新闻

月新闻