产品概述
产品优势
应用场景
实例规格
安装方式 | 方法一:编译安装 Pytorch | 方法二:安装 Pytorch 通信插件 | (推荐)方法三:安装 NCCL 通信插件 |
使用步骤 | 安装 TCCL 重新编译安装 Pytorch | 安装 Pytorch 通信插件 修改分布式通信后端 | 安装 NCCL 插件 修改启动脚本 |
优点 | 对业务代码无入侵 | 安装方便 | 安装方便 |
缺点 | 需要重新编译安装 Pytorch 对软件环境有要求 | 需要修改业务代码 对软件环境有要求 | 集群节点扩充之后,需要更新排序列表 |
软件环境依赖 | 对应 NCCL 版本 2.12 要求 glibc 版本 2.17 以上 要求 CUDA 版本 10.0 以上 | 当前安装包仅支持 Pytorch 1.12 要求 glibc 版本 2.17 以上
要求 CUDA 版本 10.0 以上 | 安装 NCCL 即可 |
# 卸载已有tccl版本和nccl插件dpkg -r tccl && dpkg -r nccl-rdma-sharp-plugins# 下载安装tccl v1.5版本wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/tccl/TCCL_1.5-ubuntu.20.04.5_amd64.deb && dpkg -i TCCL_1.5-ubuntu.20.04.5_amd64.deb && rm -f TCCL_1.5-ubuntu.20.04.5_amd64.deb
# 卸载已有tccl版本和nccl插件rpm -e tccl && rpm -e nccl-rdma-sharp-plugins-1.0-1.x86_64# 下载tccl v1.5版本wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/tccl/tccl-1.5-1.tl2.x86_64.rpm && rpm -ivh --nodeps --force tccl-1.5-1.tl2.x86_64.rpm && rm -f tccl-1.5-1.tl2.x86_64.rpm
#!/bin/bash# 卸载当前版本pip uninstall -y torch# 下载pytorch源码git clone --recursive https://github.com/pytorch/pytorchcd pytorch# <!重要> 配置TCCL的安装路径export USE_SYSTEM_NCCL=1export NCCL_INCLUDE_DIR="/opt/tencent/tccl/include"export NCCL_LIB_DIR="/opt/tencent/tccl/lib"# 参考官网添加其他编译选项# 安装开发环境python setup.py develop
export NCCL_DEBUG=INFOexport NCCL_SOCKET_IFNAME=eth0export NCCL_IB_GID_INDEX=3export NCCL_IB_DISABLE=0export NCCL_IB_HCA=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3,mlx5_bond_4,mlx5_bond_5,mlx5_bond_6,mlx5_bond_7export NCCL_NET_GDR_LEVEL=2export NCCL_IB_QPS_PER_CONNECTION=4export NCCL_IB_TC=160export NCCL_IB_TIMEOUT=22export NCCL_PXN_DISABLE=0export TCCL_TOPO_AFFINITY=4

export LD_LIBRARY_PATH=/opt/tencent/tccl/lib:$LD_LIBRARY_PATH
# 卸载现有的tccl和NCCL插件dpkg -r tccl && dpkg -r nccl-rdma-sharp-plugins# 卸载torch_tcclpip uninstall -y torch-tccl# 安装torch_tccl 0.0.2版本wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/tccl/torch_tccl-0.0.2_pt1.12-py3-none-any.whl && pip install torch_tccl-0.0.2_pt1.12-py3-none-any.whl && rm -f torch_tccl-0.0.2_pt1.12-py3-none-any.whl
import torch_tccl#args.dist_backend = "nccl"args.dist_backend = "tccl"torch.distributed.init_process_group(backend=args.dist_backend,init_method=args.dist_url,world_size=args.world_size, rank=args.rank)
export NCCL_DEBUG=INFOexport NCCL_SOCKET_IFNAME=eth0export NCCL_IB_GID_INDEX=3export NCCL_IB_DISABLE=0export NCCL_IB_HCA=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3,mlx5_bond_4,mlx5_bond_5,mlx5_bond_6,mlx5_bond_7export NCCL_NET_GDR_LEVEL=2export NCCL_IB_QPS_PER_CONNECTION=4export NCCL_IB_TC=160export NCCL_IB_TIMEOUT=22export NCCL_PXN_DISABLE=0export TCCL_TOPO_AFFINITY=4

# 卸载现有的 tccl 和 nccl 插件dpkg -r tccl && dpkg -r nccl-rdma-sharp-plugins# 下载安装 nccl 1.2 插件wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/nccl/nccl-rdma-sharp-plugins_1.2_amd64.deb && dpkg -i nccl-rdma-sharp-plugins_1.2_amd64.deb# 请确保集群内使用的 nccl 插件版本一致,以下为 nccl 1.0 版本下载安装命令,推荐使用稳定性更优的 nccl 1.2 版本# wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/nccl/nccl-rdma-sharp-plugins_1.0_amd64.deb && dpkg -i nccl-rdma-sharp-plugins_1.0_amd64.deb && rm -f nccl-rdma-sharp-plugins_1.0_amd64.deb
# 卸载现有的 nccl 插件rpm -e nccl-rdma-sharp-plugins-1.0-1.x86_64# 下载安装 nccl 1.2 插件wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/nccl/nccl-rdma-sharp-plugins-1.2-1.x86_64.rpm && rpm -ivh --nodeps --force nccl-rdma-sharp-plugins-1.2-1.x86_64.rpm# 请确保集群内使用 nccl 插件版本一致,以下为 nccl 1.0 版本下载安装命令,推荐使用稳定性更优的 nccl 1.2 版本# wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/nccl/nccl-rdma-sharp-plugins-1.0-1.x86_64.rpm && rpm -ivh --nodeps --force nccl-rdma-sharp-plugins-1.0-1.x86_64.rpm && rm -f nccl-rdma-sharp-plugins-1.0-1.x86_64.rpm
ifconfig eth0获取,每行1个节点 IP,格式如下:root@VM-125-10-tencentos:/workspace# cat ip_eth0.txt172.16.177.28172.16.176.11172.16.177.25172.16.177.12
wget https://taco-1251783334.cos.ap-shanghai.myqcloud.com/tccl/get_rdma_order_by_ip.sh && bash get_rdma_order_by_ip.sh ip_eth0.txt
apt install curl 安装)。root@VM-125-10-tencentos:/workspace# cat hostfile.txt172.16.176.11172.16.177.12172.16.177.25172.16.177.28
export NCCL_DEBUG=INFOexport NCCL_SOCKET_IFNAME=eth0export NCCL_IB_GID_INDEX=3export NCCL_IB_DISABLE=0export NCCL_IB_HCA=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3,mlx5_bond_4,mlx5_bond_5,mlx5_bond_6,mlx5_bond_7export NCCL_NET_GDR_LEVEL=2export NCCL_IB_QPS_PER_CONNECTION=4export NCCL_IB_TC=160export NCCL_IB_TIMEOUT=22export NCCL_PXN_DISABLE=0# 机器IP手动排序之后,就不需要添加如下变量了# export TCCL_TOPO_AFFINITY=4
root@vm-3-17-centos:/workspace/ptm/gpt# cat hostfile172.16.176.11 slots=8172.16.177.12 slots=8172.16.177.25 slots=8172.16.177.28 slots=8deepspeed --hostfile ./hostfile --master_addr 172.16.176.11 train.py
--node_rank 指定对应的节点顺序,// on 172.16.176.11torchrun --nnodes=4 --nproc_per_node=8 --node_rank=0 --master_addr=172.16.176.11 train.py ...// on 172.16.176.12torchrun --nnodes=4 --nproc_per_node=8 --node_rank=1 --master_addr=172.16.176.11 train.py ...// on 172.16.176.25torchrun --nnodes=4 --nproc_per_node=8 --node_rank=2 --master_addr=172.16.176.11 train.py ...// on 172.16.176.28torchrun --nnodes=4 --nproc_per_node=8 --node_rank=3 --master_addr=172.16.176.11 train.py ...
mpirun \\-np 64 \\-H 172.16.176.11:8,172.16.177.12:8,172.16.177.25:8,172.16.177.28:8 \\--allow-run-as-root \\-bind-to none -map-by slot \\-x NCCL_DEBUG=INFO-x NCCL_IB_GID_INDEX=3 \\-x NCCL_IB_DISABLE=0 \\-x NCCL_SOCKET_IFNAME=eth0 \\-x NCCL_IB_HCA=mlx5_bond_0,mlx5_bond_1,mlx5_bond_2,mlx5_bond_3,mlx5_bond_4,mlx5_bond_5,mlx5_bond_6,mlx5_bond_7 \\-x NCCL_NET_GDR_LEVEL=2 \\-x NCCL_IB_QPS_PER_CONNECTION=4 \\-x NCCL_IB_TC=160 \\-x NCCL_IB_TIMEOUT=22 \\-x NCCL_PXN_DISABLE=0 \\-x LD_LIBRARY_PATH -x PATH \\-mca coll_hcoll_enable 0 \\-mca pml ob1 \\-mca btl_tcp_if_include eth0 \\-mca btl ^openib \\all_reduce_perf -b 1G -e 1G -n 1000 -g 1
文档反馈