使用NVIDIA GPU和SmartNIC的边缘AI

第一篇文章描述了 如何使用预装驱动程序集成英伟达 gpu 和网络运营商 。
本文介绍了以下任务:
清理预安装的驱动程序集成
使用自定义驱动程序容器安装网络运营商
使用自定义驱动程序容器安装 gpu 操作员
nvidia 驱动程序集成
预安装的驱动程序集成方法适用于需要签名驱动程序的边缘部署,以实现安全和可测量的引导。当边缘节点具有不可变的操作系统时,请使用驱动程序容器方法。当并非所有边缘节点都有加速器时,驱动程序容器也适用。
清理预安装的驱动程序集成
首先,卸载以前的配置并重新启动以清除预安装的驱动程序。
删除测试播客和网络附件。
$ kubectl delete pod roce-shared-podpod roce-shared-pod deleted $ kubectl delete macvlannetwork roce-shared-macvlan-networkmacvlannetwork.mellanox.com roce-shared-macvlan-network deleted 卸载网络运营商掌舵图。$ helm delete -n network-operator network-operatorrelease network-operator uninstalled 3 .卸载 mofed 以删除预安装的驱动程序和库。
$ rmmod nvidia_peermem $ /etc/init.d/openibd stopunloading hca driver: [ ok ] $ cd ~/mlnx_ofed_linux-5.4-1.0.3.0-rhel7.9-x86_64 $ ./uninstall.sh 4 .拆下 gpu 测试盒。
$ kubectl delete pod cuda-vectoraddpod cuda-vectoradd deleted 5 .卸载英伟达 linux 驱动程序。
$ ./nvidia-linux-x86_64-470.57.02.run --uninstall 6 .拆下 gpu 操作器。
$ helm uninstall gpu-operator-1634173044 7 .重新启动。
$ sudo shutdown -r now 使用自定义驱动程序容器安装网络运营商
本节介绍使用自定义驱动程序容器安装网络运营商的步骤。
在容器映像中执行的驱动程序构建脚本需要访问目标内核的内核开发包。在本例中,内核开发包是通过 apacheweb 服务器提供的。
构建容器后,将其上载到网络运营商 helm chart 可以从主机访问的存储库。
gpu 操作员将在下一节中使用相同的 web 服务器构建自定义 gpu 操作员驱动程序容器。
安装 apache web 服务器并启动它。
$ sudo firewall-cmd --statenot running $ sudo yum install createrepo yum-utils httpd -y $ systemctl start httpd.service && systemctl enable httpd.service && systemctl status httpd.service● httpd.service - the apache http server loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) active: active (running) since wed 2021-10-20 18:10:43 edt; 4h 45min ago... 创建上游 centos 7 基本软件包存储库的镜像。自定义包存储库在/ var 分区上需要 500 gb 的可用空间。请注意,将所有 centos base 软件包下载到 web 服务器可能需要 10 分钟或更长时间。$ cd /var/www/html$ mkdir -p repos/centos/7/x86_64/os$ reposync -p /var/www/html/repos/centos/7/x86_64/os/ --repo=base --download-metadata -m 3 .将 linux 内核源文件复制到 web 服务器上的 base packages 目录中。本例假设使用 rpmbuild 将自定义内核编译为 rpm 。
$ cd repos/centos/7/x86_64/os$ sudo cp ~/rpmbuild/rpms/x86_64/*.rpm . 网络运营商需要以下文件:
kernel-headers-${kernel_version} kernel-devel-${kernel_version} 确保 gpu 操作员有这些附加文件:
gcc-${gcc_version} elfutils-libelf.x86_64 elfutils-libelf-devel.x86_64$ for i in $(rpm -q kernel-headers kernel-devel elfutils-libelf elfutils-libelf-devel gcc | grep -v not installed); do ls $i*; donekernel-headers-3.10.0-1160.42.2.el7.custom.x86_64.rpmkernel-devel-3.10.0-1160.42.2.el7.custom.x86_64.rpmelfutils-libelf-0.176-5.el7.x86_64.rpmelfutils-libelf-devel-0.176-5.el7.x86_64.rpmgcc-4.8.5-44.el7.x86_64.rpm 4 .浏览到 web 存储库以确保可通过 http 访问该存储库。
$ elinks http://localhost/repos/centos/7/x86_64/os --dump index of /repos/centos/7/x86_64/os [1][ico] [2]name [3]last modified [4]size [5]description -------------------------------------------------------------------------- [6][parentdir] [7]parent directory - [8][dir] [9]base/ 2021-10-21 22:55 - [10][dir] [11]extras/ 2021-10-02 00:29 - -------------------------------------------------------------------------- references visible links 2. http://localhost/repos/centos/7/x86_64/os/?c=n;o=d 3. http://localhost/repos/centos/7/x86_64/os/?c=m;o=a 4. http://localhost/repos/centos/7/x86_64/os/?c=s;o=a 5. http://localhost/repos/centos/7/x86_64/os/?c=d;o=a 7. http://localhost/repos/centos/7/x86_64/ 9. http://localhost/repos/centos/7/x86_64/os/base/ 11. http://localhost/repos/centos/7/x86_64/os/extras/ 5.mofed 驱动程序容器映像是根据 github 上 mellanox/ofed-docker 存储库中的源代码构建的。克隆 ofed docker 存储库。
$ git clone https://github.com/mellanox/ofed-docker.git$ cd ofed-docker/ 6 .为自定义驱动程序容器创建生成目录。
$ mkdir centos$ cd centos/ 7 .创建 dockerfile ,将 mofed 依赖项和源存档安装到 centos 7.9 基本映像中。指定 mofed 和 centos 版本。
$ sudo cat << eof | tee dockerfilefrom centos:centos7.9.2009 arg d_ofed_version=5.4-1.0.3.0arg d_os_version=7.9arg d_os=rhel${d_os_version}env d_os=${d_os}arg d_arch=x86_64arg d_ofed_path=mlnx_ofed_linux-${d_ofed_version}-${d_os}-${d_arch}env d_ofed_path=${d_ofed_path} arg d_ofed_tarball_name=${d_ofed_path}.tgzarg d_ofed_base_url=https://www.mellanox.com/downloads/ofed/mlnx_ofed-${d_ofed_version}arg d_ofed_url_path=${d_ofed_base_url}/${d_ofed_tarball_name} arg d_without_flags=--without-rshim-dkms --without-iser-dkms --without-isert-dkms --without-srp-dkms --without-kernel-mft-dkms --without-mlnx-rdma-rxe-dkmsenv d_without_flags=${d_without_flags} # download and extract tarballworkdir /rootrun yum install -y curl && (curl -sl ${d_ofed_url_path} | tar -xzf -) run yum install -y atk \ cairo \ ethtool \ gcc-gfortran \ git \ gtk2 \ iproute \ libnl3 \ libxml2-python \ lsof \ make \ net-tools \ numactl-libs \ openssh-clients \ openssh-server \ pciutils \ perl \ python-devel \ redhat-rpm-config \ rpm-build \ tcl \ tcsh \ tk \ wget add ./entrypoint.sh /root/entrypoint.sh entrypoint [/root/entrypoint.sh]eof 8 .修改 ofed docker 存储库中包含的 rhel entrypoint.sh 脚本,以从 web 服务器安装自定义内核源程序包。在 _install_prerequsities() 函数中指定 web 服务器上 base/packages 目录的路径。
在本例中, 10.150.168.20 是本节前面创建的 web 服务器 ip 地址。
$ cp ../rhel/entrypoint.sh .$ cat entrypoint.sh...# install the kernel modules header/builtin/order files and generate the kernel version string._install_prerequisites() { echo installing dependencies yum -y --releasever=7 install createrepo elfutils-libelf-devel kernel-rpm-macros numactl-libs initscripts grubby linux-firmware libtool echo installing linux kernel headers... rpm -ivh http://10.150.168.20/repos/centos/7/x86_64/os/base/packages/kernel-3.10.0-1160.45.1.el7.custom.x86_64.rpm rpm -ivh http://10.150.168.20/repos/centos/7/x86_64/os/base/packages/kernel-devel-3.10.0-1160.45.1.el7.custom.x86_64.rpm rpm -ivh http://10.150.168.20/repos/centos/7/x86_64/os/base/packages/kernel-headers-3.10.0-1160.45.1.el7.custom.x86_64.rpm # prevent depmod from giving a warning about missing files touch /lib/modules/${kver}/modules.order touch /lib/modules/${kver}/modules.builtin depmod ${kver}... 9ofed 驱动程序容器从主机文件系统装载一个目录以共享驱动程序文件。创建目录。
$ mkdir -p /run/mellanox/drivers 10 将新的 centos 驱动程序映像上载到注册表。此示例使用 ngc 专用注册表。登录到注册表。
$ sudo yum install -y podman $ sudo podman login nvcr.iousername: $oauthtokenpassword: *****************************************login succeeded! 11 使用 podman 构建驱动程序容器映像并将其推送到注册表。
$ sudo podman build --no-cache --tag nvcr.io/nv-ngc5g/mofed-5.4-1.0.3.0:centos7-amd64 . 12 标记图像并将其推送到注册表。
$ sudo podman images nvcr.io | grep mofednvcr.io/nv-ngc5g/mofed-5.4-1.0.3.0 centos7-amd64 d61e555bddda 2 minutes ago 1.13 gb 13 覆盖英伟达网络运营商头盔图中包含的 value.yaml 文件,以安装自定义驱动程序映像。指定自定义驱动程序容器的映像名称、存储库和版本。
$ cat << eof | sudo tee roce_shared_values_driver.yaml nfd: enabled: falsedeploycr: trueofeddriver: deploy: true image: mofed repository: nvcr.io/nv-ngc5g version: 5.4-1.0.3.0sriovdeviceplugin: deploy: falserdmashareddeviceplugin: deploy: true resources: - name: rdma_shared_device_a vendors: [15b3] deviceids: [101d] ifnames: [ens13f0]eof 14 安装英伟达网络运营商的新价值。
$ helm install -f ./roce_shared_values_driver.yaml -n network-operator --create-namespace --wait network-operator mellanox/network-operator 15 查看网络运营商部署的 pod 。 mofed 吊舱应处于运行状态。这是自定义驱动程序容器。请注意,在启动 pod 之前编译驱动程序可能需要几分钟的时间。
$ kubectl -n nvidia-network-operator-resources get podsname ready status restarts agecni-plugins-ds-zr9kf 1/1 running 0 10mkube-multus-ds-w57rz 1/1 running 0 10mmofed-centos7-ds-cbs74 1/1 running 0 10mrdma-shared-dp-ds-ch8m2 1/1 running 0 2m27swhereabouts-z947f 1/1 running 0 10m 16 验证主机上是否加载了 mofed 驱动程序。
$ lsmod | egrep '^ib|^mlx|^rdma'rdma_ucm 27022 0 rdma_cm 65212 1 rdma_ucmib_ipoib 124872 0 ib_cm 53085 2 rdma_cm,ib_ipoibib_umad 27744 0 mlx5_ib 384793 0 mlx5_core 1360822 1 mlx5_ibib_uverbs 132833 2 mlx5_ib,rdma_ucmib_core 357959 8 rdma_cm,ib_cm,iw_cm,mlx5_ib,ib_umad,ib_uverbs,rdma_ucm,ib_ipoibmlx_compat 55063 11 rdma_cm,ib_cm,iw_cm,auxiliary,mlx5_ib,ib_core,ib_umad,ib_uverbs,mlx5_core,rdma_ucm,ib_ipoibmlxfw 22321 1 mlx5_core 17 驱动程序容器的根文件系统应绑定到主机上的 /run/mellanox/drivers 目录。
$ ls /run/mellanox/driversanaconda-post.log bin boot dev etc home host lib lib64 media mnt opt proc root run sbin srv sys tmp usr var 使用自定义驱动程序容器安装 gpu 操作员
本节介绍使用自定义驱动程序容器安装 gpu 操作符的步骤。
与网络运营商一样, gpu 运营商容器执行的驱动程序构建脚本需要访问目标内核的开发包。
本例使用的 web 服务器与上一节中向网络运营商交付开发包的 web 服务器相同。
构建容器后,将其上载到 gpu 操作员 helm chart 可以从主机访问的存储库。与网络运营商示例一样, gpu 运营商也使用 ngc 上的专用注册表。
构建自定义驱动程序容器。
$ cd ~$ git clone https://gitlab.com/nvidia/container-images/driver.git$ cd driver/centos7 2 .更新 centos dockerfile 以使用驱动程序版本 470.74 。注释掉未使用的参数。
$ grep arg dockerfile arg base_url=http://us.download.nvidia.com/xfree86/linux-x86_64#arg base_url=https://us.download.nvidia.com/teslaarg driver_version=470.74arg driver_type=passthrougharg vgpu_license_server_type=fnearg public_key=''#arg public_key=emptyarg private_key 3 .构建 gpu 驱动程序容器映像并将其推送到 ngc 。
$ sudo podman build --no-cache --tag nvcr.io/nv-ngc5g/driver:470.74-centos7 . 4 .查看 gpu 驱动程序容器图像。
$ podman images nvcr.io | grep 470nvcr.io/nv-ngc5g/driver 470.74-centos7 630f0f8e77f5 2 minutes ago 1.28 gb 5 .验证为网络运营商安装创建的自定义存储库中是否存在以下文件:
elfutils-libelf.x86_64 elfutils-libelf-devel.x86_64 kernel-headers-${kernel_version} kernel-devel-${kernel_version} gcc-${gcc_version} 编译自定义内核映像的驱动程序需要这些文件。
$ cd /var/www/html/repos/centos/7/x86_64/os/base/packages/ $ for i in $(rpm -q kernel-headers kernel-devel elfutils-libelf elfutils-libelf-devel gcc | grep -v not installed); do ls $i*; donekernel-headers-3.10.0-1160.45.1.el7.custom.x86_64.rpmkernel-devel-3.10.0-1160.45.1.el7.custom.x86_64.rpmelfutils-libelf-0.176-5.el7.x86_64.rpmelfutils-libelf-devel-0.176-5.el7.x86_64.rpmgcc-4.8.5-44.el7.x86_64.rpm 6 .与网络运营商不同, gpu 运营商使用自定义的 yum 存储库配置文件。创建引用自定义镜像存储库的 yum repo 文件。
$ cd /var/www/html/repos $ cat << eof | sudo tee custom-repo.repo [base]name=centos linux $releasever - basebaseurl=http://10.150.168.20/repos/centos/$releasever/$basearch/os/base/gpgcheck=0enabled=1eof 7.gpu 运算符使用 kubernetes configmap 来配置自定义存储库。 configmap 必须在 gpu-operator-resources 命名空间中可用。创建名称空间和 configmap 。
$ kubectl create ns gpu-operator-resources $ kubectl create configmap repo-config -n gpu-operator-resources --from-file=/var/www/html/repos/custom-repo.repoconfigmap/repo-config created $ kubectl describe cm -n gpu-operator-resources repo-config name: repo-confignamespace: gpu-operator-resourceslabels: annotations: data====custom-repo.repo:----[base]name=centos linux $releasever - basebaseurl=http://10.150.168.20/repos/centos/$releasever/$basearch/os/base/gpgcheck=0enabled=1 8 .安装 gpu 操作员舵图。指定自定义存储库位置、自定义驱动程序版本以及自定义驱动程序映像名称和位置。
$ helm install nvidia/gpu-operator --generate-name --set driver.repoconfig.configmapname=repo-config --set driver.repoconfig.destinationdir=/etc/yum.repos.d --set driver.image=driver --set driver.repository=nvcr.io/nv-ngc5g --set-string driver.version=\470.74\ --set toolkit.version=1.7.1-centos7 --set operator.defaultruntime=crio 9 查看已部署的吊舱。
$ kubectl get pods -n gpu-operator-resourcesname ready status restarts agegpu-feature-discovery-r6kq6 1/1 running 0 3m33snvidia-container-toolkit-daemonset-62pbj 1/1 running 0 3m33snvidia-cuda-validator-ljd5l 0/1 completed 0 119snvidia-dcgm-9nsfx 1/1 running 0 3m33snvidia-dcgm-exporter-zm82v 1/1 running 0 3m33snvidia-device-plugin-daemonset-bp66r 1/1 running 0 3m33snvidia-device-plugin-validator-8pbmv 0/1 completed 0 108snvidia-driver-daemonset-4tx24 1/1 running 0 3m33snvidia-mig-manager-kvcgc 1/1 running 0 3m32snvidia-operator-validator-g9xz5 1/1 running 0 3m33s 10 验证驱动程序是否已加载。
$ lsmod | grep nvidianvidia_modeset 1195268 0 nvidia_uvm 995356 0 nvidia 35237551 114 nvidia_modeset,nvidia_uvmdrm 456166 5 ast,ttm,drm_kms_helper,nvidia 11 从驱动程序守护程序盒运行 nvidia smi 。
defaulted container nvidia-driver-ctr out of: nvidia-driver-ctr, k8s-driver-manager (init)thu oct 28 02:37:50 2021 +-----------------------------------------------------------------------------+| nvidia-smi 470.74 driver version: 470.74 cuda version: 11.4 ||-------------------------------+----------------------+----------------------+| gpu name persistence-m| bus-id disp.a | volatile uncorr. ecc || fan temp perf pwr:usage/cap| memory-usage | gpu-util compute m. || | | mig m. ||===============================+======================+======================|| 0 nvidia a100-pci... on | 00000000:23:00.0 off | 0 || n/a 25c p0 32w / 250w | 0mib / 40536mib | 0% default || | | disabled |+-------------------------------+----------------------+----------------------+| 1 nvidia a100-pci... on | 00000000:e6:00.0 off | 0 || n/a 27c p0 32w / 250w | 0mib / 40536mib | 0% default || | | disabled |+-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+| processes: || gpu gi ci pid type process name gpu memory || id id usage ||=============================================================================|| no running processes found |+-----------------------------------------------------------------------------+ 启用 gpundeid-rdma 的英伟达对等存储器驱动器不是自动构建的。
重复此过程以构建自定义 nvidia peermem 驱动程序容器。
对于 gpu 运营商中的 nvidia peermem 安装程序尚不支持的任何 linux 操作系统,都需要此附加步骤。
英伟达加速器的未来
nvidia 加速器有助于在传感器数据呈指数级增长的情况下,对未来的边缘 ai 投资进行验证。 nvidia 运营商是云本地软件,可简化 kubernetes 上的加速器部署和管理。运营商支持流行的 kubernetes 开箱即用平台,并且可以定制以支持替代平台。
关于作者
jacob liberman 是 nvidia 企业和边缘加速集团的产品经理。他利用 20 多年的技术计算经验提供高性能、云计算原生边缘人工智能解决方案。此前,他曾在红帽、 amd 和戴尔担任产品管理和工程职务。


你真的懂网络安全吗?密钥的分配解析
国产施密特触发器AiP74LVC2G14可原位替代TI的SN74LVC2G14
光纤HDMI连接器的质量对画质影响有多大
人工智能时代 智能安防场景爆发机遇
高压灯条、高压灯带高压线性恒流芯片方案LK2085的设计
使用NVIDIA GPU和SmartNIC的边缘AI
基于超声换能器阻抗匹配原理对超声手术刀进行频率跟踪
骁龙835后,高通10nm制程另曝新品Qualcomm Centriq 2400服务器处理器问世
揭秘国内主要电动夹爪厂商的专利技术分布:创新领域与竞争优势
CCEF新品:Garmin机座、USB通用充电器
什么是LED倒装芯片?LED倒装芯片制备流程
个人食品计算机可以免费获得设备规格和代码
全球公有云带头大哥AWS不断重塑价值
贸博士看财报观趋势--要靠汽车电子续命了?
物联网:嵌入式和安全
6600mah+7.9寸视网膜屏,小米平板3能从iPad、联想、华为口中夺食么
从入门到精通,泰克为工程师特别开设电源纹波测试课堂
微秒成功研发移动机器人驱动器,抢占了市场的制高点
5G NR无线电出货量在2020年上半年期间增长了6倍
协作机器人的诞生史回顾,向勇于创新的行业先行者致敬