昇腾多卡通信教程【配置网络检测对象IP】

无法通信会出现的错误如下

一、网络健康状态报错

命令原型

hccn_tool [-i %d] -netdetect -s [address %s]

命令功能
本功能支持用户执行命令获取网络健康状态(本端与所配置的检测IP之间的连通状态),用户可指定上报的状态信息名称。

状态信息:

0:Success;1:Socket fail;2:Receive timeout;3:Unreachable;4:Time exceeded;5:Fault;6:Init;7:Thread error;8:Detect ip set;其它:Unknown。

参数说明

参数 说明
-i 指定设备ID。取值范围:0~7。
-net_health 指定网络健康状态属性。
-g 获取属性。

使用样例

hccn_tool -i 1 -net_health -g

报错

net health status: Init

二、运行hccl_tools.py报错

根据RANK_TABLE_FILE准备----单机8卡
运行mindformers/tools/hccl_tools.py,生成RANK_TABLE_FILE文件

# 运行如下命令,生成当前机器的RANK_TABLE_FILE的json文件
python ./mindformers/tools/hccl_tools.py --device_num "[0,8)"

报错

start /home/HwHiAiUser/mindformers/./mindformers/tools/hccl_tools.py
visible_devices:['0', '1', '2', '3', '4', '5', '6', '7']
server_id:127.0.0.1
device_num_list: [0, 1, 2, 3, 4, 5, 6, 7]
Command execute failed!
Failed to call hccn_tool, try to read /etc/hccn.conf instead
Traceback (most recent call last):
  File "/home/HwHiAiUser/mindformers/./mindformers/tools/hccl_tools.py", line 163, in <module>
    main()
  File "/home/HwHiAiUser/mindformers/./mindformers/tools/hccl_tools.py", line 137, in main
    device_ip = device_ips[device_id]
KeyError: '0'

三、多卡推理报错

多卡推理baichuan2-13b,这个时候已经解决了上面的报错,但是这时多卡依然无法通信,报错EI0004,官网论坛以及昇思文档还有gitee都没有解决方案
报错

[WARNING] Distributed Communication has not been inited. Use default RANK_SIZE: 1
[WARNING] Distributed Communication has not been inited. Use default RANK_ID: 0
Traceback (most recent call last):
 File "/home/anaconda3/envs/sakura/lib/python3.9/site-packages/mindformers/core/context/build_context.py", line 95, in init_context
   init()
 File "/home/anaconda3/envs/sakura/lib/python3.9/site-packages/mindspore/communication/management.py", line 171, in init
   init_hccl()
RuntimeError: Ascend collective communication initialization failed.

----------------------------------------------------
- Ascend Error Message:
----------------------------------------------------
EI0004: The ranktable or rank is invalid,Reason:[The ranktable config devId is inconsistent with the local devId.]. Please check the configured ranktable. [{
   "server_count":"1","server_list":[{
   "device":[{
   "device_id":"0","device_ip":"192.168.2.60","rank_id":"0"},{
   "device_id":"1","device_ip":"192.168.3.60","rank_id":"1"},{
   "device_id":"2","device_ip":"192.168.4.60","rank_id":"2"},{
   "device_id":"3","device_ip":"192.168.5.60","rank_id":"3"},{
   "device_id":"4","device_ip":"192.168.6.60","rank_id":"4"},{
   "device_id":"5","device_ip":"192.168.7.60","rank_id":"5"},{
   "device_id":"6","device_ip":"192.168.8.60","rank_id":"6"},{
   "device_id":"7","device_ip":"192.168.9.60","rank_id":"7"}],"host_nic_ip":"reserve","server_id":"127.0.0.1"}],"status":"completed","version":"1.0"}]
       Solution: Try again with a valid cluster configuration in the ranktable file. Ensure that the configuration matches the operating environment.

(Please search "Ascend Error Message" at https://www.mindspore.cn for error code description)

----------------------------------------------------
- Framework Error Message: (For framework developers)
----------------------------------------------------
Init hccl graph adapter failed.
----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore/ccsrc/plugin/device/ascend/hal/hardware/ascend_collective_comm_lib.cc:129 Initialize
mindspore/ccsrc/plugin/device/ascend/hal/hccl_adapter/hccl_adapter.cc:452 InitKernelInfoStore


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "/home/HwHiAiUser/mindformers/research/baichuan2/run_baichuan2_pipeline.py", line 35, in <module>
   build_context(baichuan2_config)
 File "/home/anaconda3/envs/sakura/lib/python3.9/site-packages/mindformers/core/context/build_context.py", line 43, in build_context
   local_rank, device_num = init_context(use_parallel=config.use_parallel,
 File "/home/anaconda3/envs/sakura/lib/python3.9/site-packages/mindformers/core/context/build_context.py", line 97, in init_context
   raise RuntimeError("Notice: if you are trying to run with a single device, please set "
RuntimeError: Notice: if you are trying to run with a single device, please set use_parallel=False. If not, please check the error message above.

解决方案

第一步:编译HCCL

参考:昇腾社区—CANN社区版—开发工具—HCCL性能测试工具—工具编译

第二步:配置网卡

1、RoCE网卡IP地址和子网掩码

命令原型

hccn_tool [-i %d] -ip -s [address %s] [netmask %s]

命令功能
配置RoCE网卡的IP地址、子网掩码。

参数说明

参数 说明
-i 指定设备ID。取值范围:0~7。
-ip 指定IP属性。
-s 设置属性。
address IP地址。
netmask 子网掩码。

约束说明
该命令仅支持在物理机root用户下运行。

使用样例

hccn_tool -i 0 -ip -s address 192.168.10.61 netmask 255.255.255.0
hccn_tool -i 1 -ip -s address 192.168.10.62 netmask 255.255.255.0
hccn_tool -i 2 -ip -s address 192.168.10.63 netmask 255.255.255.0
hccn_tool -i 3 -ip -s address 192.168.10.64 netmask 255.255.255.0
hccn_tool -i 4 -ip -s address 192.168.10.65 netmask 255.255.255.0
hccn_tool -i 5 -ip -s address 192.168.10.66 netmask 255.255.255.0
hccn_tool -i 6 -ip -s address 192.168.10.67 netmask 255.255.255.0
hccn_tool -i 7 -ip -s address 192.168.10.68 netmask 255.255.255.0

注意事项
我的服务器IP是192.168.10.60,所以设置显卡ip需要以192.168.10为起始
针对AI Server上每个Device侧OS管理8块昇腾AI处理器,需要为每个OS上的8块网卡配置不同的IP。
首次配置IP时会出现15秒后link状态变为down,然后恢复up状态的情况。
192.168.1.X、192.168.2.192、192.168.2.196、192.168.3.193、192.168.3.197、192.168.4.194、192.168.4.198、192.168.5.195和192.168.5.199用于板内网络通信使用,不支持配置。

2、配置路由

hccn_tool -i 0 -gateway -s gateway 192.168.10.60
hccn_tool -i 1 -gateway -s gateway 192.168.10.60
hccn_tool -i 2 -gateway -s gateway 192.168.10.60
hccn_tool -i 3 -gateway -s gateway 192.168.10.60
hccn_tool -i 4 -gateway -s gateway 192.168.10.60
hccn_tool -i 5 -gateway -s gateway 192.168.10.60
hccn_tool -i 6 -gateway -s gateway 192.168.10.60
hccn_tool -i 7 -gateway -s gateway 192.168.10.60

3、配置NPU网口检测IP地址(网络检测对象IP)

命令原型

hccn_tool [-i %d] -netdetect -s [address %s]

命令功能
配置网络检测对象IP。该功能主要用于检测网络状态,当多台服务器进行分布式训练时,可将检测对象IP配置为网段内的网关地址,服务器会定时检测和网关地址通信是否正常,从而实现检测服务器参数面网络状态是否正常的效果。该功能需配合获取网络健康状态使用。

参数说明

参数 说明
-i 指定设备ID。取值范围:0~7。
-netdetect 指定网络检测对象IP属性。
-s 设置属性。
address IP地址。

约束说明
该命令仅支持在物理机的root用户下运行。

使用样例

hccn_tool -i 0 -netdetect -s address 192.168.10.60
hccn_tool -i 1 -netdetect -s address 192.168.10.60
hccn_tool -i 2 -netdetect -s address 192.168.10.60
hccn_tool -i 3 -netdetect -s address 192.168.10.60
hccn_tool -i 4 -netdetect -s address 192.168.10.60
hccn_tool -i 5 -netdetect -s address 192.168.10.60
hccn_tool -i 6 -netdetect -s address 192.168.10.60
hccn_tool -i 7 -netdetect -s address 192.168.10.60

官网给的教程里ip地址要对应路由地址,对应网关地址,但是这样设置后会显示net health status: Receive timeout
我改完RoCE网卡IP地址后才会显示成功,也就是


hccn_tool -i 0 -netdetect -s address 192.168.10.61
hccn_tool -i 1 -netdetect -s address 192.168.10.62
hccn_tool -i 2 -netdetect -s address 192.168.10.63
hccn_tool -i 3 -netdetect -s address 192.168.10.64
hccn_tool -i 4 -netdetect -s address 192.168.10.65
hccn_tool -i 5 -netdetect -s address 192.168.10.66
hccn_tool -i 6 -netdetect -s address 192.168.10.67
hccn_tool -i 7 -netdetect -s address 192.168.10.68

设置完成后随意检查一块显卡的健康状态

hccn_tool -i 7 -net_health -g

返回Success即为成功,这样就解决了bug-1和bug-3

net health status: Success

以上操作参考Ascend Training Solution 23.0.RC3 组网指南 01

设置完成后运行hccl_tools.py

start /home/HwHiAiUser/mindformers/./mindformers/tools/hccl_tools.py
visible_devices:['0', '1', '2', '3', '4', '5', '6', '7']
server_id:127.0.0.1
device_num_list: [0, 1, 2, 3, 4, 5, 6, 7]
rank_id:0, device_id:0, device_ip:192.168.10.61
rank_id:1, device_id:1, device_ip:192.168.10.62
rank_id:2, device_id:2, device_ip:192.168.10.63
rank_id:3, device_id:3, device_ip:192.168.10.64
rank_id:4, device_id:4, device_ip:192.168.10.65
rank_id:5, device_id:5, device_ip:192.168.10.66
rank_id:6, device_id:6, device_ip:192.168.10.67
rank_id:7, device_id:7, device_ip:192.168.10.68
Completed: hccl file was save in : /home/HwHiAiUser/mindformers/hccl_8p_01234567_127.0.0.1.json

这样就算是成功了,bug-2就解决了

相关推荐

  1. 通信教程配置网络检测对象IP

    2024-01-08 11:40:02       53 阅读
  2. 网络通信网卡配置ip

    2024-01-08 11:40:02       49 阅读
  3. 通过配置IP路由解决网卡配置同网段IP的问题

    2024-01-08 11:40:02       29 阅读
  4. 网卡IP配置netplan

    2024-01-08 11:40:02       184 阅读
  5. npu上构建modelbox webUI开发容器教程

    2024-01-08 11:40:02       74 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-08 11:40:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-08 11:40:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-08 11:40:02       87 阅读
  4. Python语言-面向对象

    2024-01-08 11:40:02       96 阅读

热门阅读

  1. 树莓派Ubuntu:屏幕截图

    2024-01-08 11:40:02       67 阅读
  2. uViw Dialog 对话框

    2024-01-08 11:40:02       68 阅读
  3. Python 的 GPIO 库

    2024-01-08 11:40:02       42 阅读
  4. Python:sqlalchemy报错DetachedInstanceError

    2024-01-08 11:40:02       53 阅读
  5. 数据库相关SQL

    2024-01-08 11:40:02       54 阅读
  6. 常用python代码大全-random模块的一些常见用法

    2024-01-08 11:40:02       61 阅读
  7. 【数据库原理】(13)视图的使用

    2024-01-08 11:40:02       54 阅读
  8. C++运算符和表达式

    2024-01-08 11:40:02       55 阅读