云服务器内容精选

  • 操作步骤 NVIDIA驱动安装。 wget https://us.download.nvidia.com/tesla/515.105.01/NVIDIA-Linux-x86_64-515.105.01.run chmod +x NVIDIA-Linux-x86_64-515.105.01.run ./NVIDIA-Linux-x86_64-515.105.01.run CUDA安装(可选,若在宿主机上不开发,可以忽略此步骤)。 wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run chmod +x cuda_11.7.1_515.65.01_linux.run ./cuda_11.7.1_515.65.01_linux.run --toolkit --samples –silent 安装Docker。 curl https://get.docker.com | sh && sudo systemctl --now enable docker 安装NIVDIA容器插件。 distribution=$(. /etc/os-release;echo $ID$VERSION_ID) && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list apt-get update apt-get install -y nvidia-container-toolkit nvidia-ctk runtime configure --runtime=docker systemctl restart docker 验证Docker模式环境是否安装成功。 基于PyTorch2.0镜像验证(本案例中镜像较大,拉取时间可能较长)。 docker run -ti --runtime=nvidia --gpus all pytorch/pytorch:2.0.0-cuda11.7-cudnn8-devel bash 图1 成功拉取镜像
  • 操作步骤 替换apt源。 sudo sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list sudo sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list sudo apt update 安装nvidia驱动。 wget https://us.download.nvidia.com/tesla/515.105.01/NVIDIA-Linux-x86_64-515.105.01.run chmod +x NVIDIA-Linux-x86_64-515.105.01.run ./NVIDIA-Linux-x86_64-515.105.01.run 安装cuda。 # run包安装 wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run chmod +x cuda_11.7.0_515.43.04_linux.run ./cuda_11.7.0_515.43.04_linux.run --toolkit --samples --silent 安装nccl。 nccl安装可参考NCCL Documentation。 nccl和cuda版本的配套关系和安装方法参考NCL Downloads。 本文使用cuda版本是11.7,因此安装nccl的命令为: wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb sudo dpkg -i cuda-keyring_1.0-1_all.deb sudo apt update sudo apt install libnccl2=2.14.3-1+cuda11.7 libnccl-dev=2.14.3-1+cuda11.7 安装完成后可以查看: 图1 查看nccl 安装nvidia-fabricmanager。 nvidia-fabricmanager必须和nvidia driver版本保持一致 version=515.105.01 main_version=$(echo $version | awk -F '.' '{print $1}') apt-get update apt-get -y install nvidia-fabricmanager-${main_version}=${version}-* 验证驱动安装结果:启动fabricmanager服务并查看状态是否为“RUNNING”。 nvidia-smi -pm 1 nvidia-smi systemctl enable nvidia-fabricmanager systemctl start nvidia-fabricmanager systemctl status nvidia-fabricmanager 安装nv-peer-memory。 git clone https://github.com/Mellanox/nv_peer_memory.git cd ./nv_peer_memory ./build_module.sh cd /tmp tar xzf /tmp/nvidia-peer-memory_1.3.orig.tar.gz cd nvidia-peer-memory-1.3 dpkg-buildpackage -us -uc dpkg -i ../nvidia-peer-memory-dkms_1.2-0_all.deb nv_peer_mem工作在linux内核态,安装完成后需要看是否加载到内核,通过执行“lsmod | grep peer”查看是否加载。 如果git clone拉不下来代码,可能需要先设置下git的配置: git config --global core.compression -1 export GIT_SSL_NO_VERIFY=1 git config --global http.sslVerify false git config --global http.postBuffer 10524288000 git config --global http.lowSpeedLimit 1000 git config --global http.lowSpeedTime 1800 如果安装完成后lsmod看不到nv-peer-memory,可能是由于ib驱动版本过低导致,此时需要升级ib驱动,升级命令: wget https://content.mellanox.com/ofed/MLNX_OFED-5.4-3.6.8.1/MLNX_OFED_LINUX-5.4-3.6.8.1-ubuntu20.04-x86_64.tgz tar -zxvf MLNX_OFED_LINUX-5.4-3.6.8.1-ubuntu20.04-x86_64.tgz cd MLNX_OFED_LINUX-5.4-3.6.8.1-ubuntu20.04-x86_64 apt-get install -y python3 gcc quilt build-essential bzip2 dh-python pkg-config dh-autoreconf python3-distutils debhelper make ./mlnxofedinstall --add-kernel-support 如果想安装其它更高版本的ib驱动,请参考Linux InfiniBand Drivers。比如要安装MLNX_OFED-5.8-2.0.3.0 (当前最新版本),则命令为: wget https://content.mellanox.com/ofed/MLNX_OFED-5.8-2.0.3.0/MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu20.04-x86_64.tgz tar -zxvf MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu20.04-x86_64.tgz cd MLNX_OFED_LINUX-5.8-2.0.3.0-ubuntu20.04-x86_64 apt-get install -y python3 gcc quilt build-essential bzip2 dh-python pkg-config dh-autoreconf python3-distutils debhelper make ./mlnxofedinstall --add-kernel-support 安装完nv_peer_mem, 如果想查看其状态可以输入如下指令: /etc/init.d/nv_peer_mem/ status 如果发现没有此文件,则可能安装的时候没有默认拷贝过来,需要拷贝即可: cp /tmp/nvidia-peer-memory-1.3/nv_peer_mem.conf /etc/infiniband/ cp /tmp/nvidia-peer-memory-1.3/debian/tmp/etc/init.d/nv_peer_mem /etc/init.d/ 设置环境变量。 MPI路径版本需要匹配,可以通过“ls /usr/mpi/gcc/”查看openmpi的具体版本。 # 加入到~/.bashrc export LD_LIBRARY_PATH=/usr/local/cuda/lib:usr/local/cuda/lib64:/usr/include/nccl.h:/usr/mpi/gcc/openmpi-4.1.2a1/lib:$LD_LIBRARY_PATH export PATH=$PATH:/usr/local/cuda/bin:/usr/mpi/gcc/openmpi-4.1.2a1/bin 安装编译nccl-test。 cd /root git clone https://github.com/NVIDIA/nccl-tests.git cd ./nccl-tests make MPI=1 MPI_HOME=/usr/mpi/gcc/openmpi-4.1.2a1 -j 8 编译时需要加上MPI=1的参数,否则无法进行多机之间的测试。 MPI路径版本需要匹配,可以通过“ls /usr/mpi/gcc/”查看openmpi的具体版本。 测试。 单机测试: /root/nccl-tests/build/all_reduce_perf -b 8 -e 1024M -f 2 -g 8 多机测试: mpirun --allow-run-as-root --hostfile hostfile -mca btl_tcp_if_include eth0 -mca btl_openib_allow_ib true -x NCCL_DEBUG=INFO -x NCCL_IB_GID_INDEX=3 -x NCCL_IB_TC=128 -x NCCL_ALGO=RING -x NCCL_IB_HCA=^mlx5_bond_0 -x LD_LIBRARY_PATH /root/nccl-tests/build/all_reduce_perf -b 8 -e 11g -f 2 -g 8 hostfile格式: #主机私有IP 单节点进程数 192.168.20.1 slots=1 192.168.20.2 slots=1 需要执行mpirun的节点到hostfile中的节点间有免密登录(如何设置SSH免密登录)。 btl_tcp_if_include后面替换为主网卡名称。 NCCL环境变量: NCCL_IB_GID_INDEX=3 :数据包走交换机的队列4通道,这是RoCE协议标准。 NCCL_IB_TC=128 :使用RoCE v2协议,默认使用RoCE v1,但是v1在交换机上没有拥塞控制,可能丢包,而且后面的交换机不会支持v1,就跑不起来了。 NCCL_ALGO=RING :nccl_test的总线bandwidth是在假定是Ring算法的情况下计算出来的。 计算公式是有假设的: 总线带宽 = 算法带宽 * 2 ( N-1 ) / N ,算法带宽 = 数据量 / 时间 但是这个计算公式的前提是用Ring算法,Tree算法的总线带宽不能这么算。 如果Tree算法算出来的总线带宽相当于是相对Ring算法的性能加速。 算法计算总耗时减少了,所以用公式算出来的总线带宽也增加了。 理论上Tree算法是比Ring算法更优的,但是Tree算法对网络的要求比Ring高,计算可能不太稳定。 Tree算法可以用更少的数据通信量完成all reduce计算,但用来测试性能不太合适。 因此,会出现两节点实际带宽100,但测试出速度110,甚至130GB/s的情况。 加这个参数以后,2节点和2节点以上情况的速度才会稳定一些。
  • 场景描述 本文旨在指导完成GP Ant8裸金属服务器装机和nccl-test测试。装机软件预览如下: 表1 装机软件 软件类型 版本详情 预置操作系统 Ubuntu 20.04 server 64bit 驱动版本 515.10.01 nvidia-cuda 11.7 nvidia-fabricmanager 515.10.01(必须和驱动版本保持一致) mlnx-ofed-linux 5.8-2.0.3.0/5.4-3.6.8.1(可选) nvidia-peer-memory-dkms 1.2-0 nccl libnccl2=2.14.3-1+cuda11.7 libnccl-dev=2.14.3-1+cuda11.7 nccl-test v.2.13.6