文档首页> 弹性云服务器 ECS> 用户指南> 实例> 安装驱动和工具包(可选)> (推荐)GPU加速型实例自动安装GPU驱动(Linux)
更新时间:2024-06-24 GMT+08:00
分享

(推荐)GPU加速型实例自动安装GPU驱动(Linux)

操作场景

在使用GPU加速型实例时,需确保实例已安装GPU驱动,否则无法获得相应的GPU加速能力。

本节内容介绍如何在GPU加速型Linux实例上通过脚本自动安装GPU驱动。

使用须知

  • 本操作仅支持Linux操作系统。
  • 本操作当前仅支持安装Tesla驱动。
  • 如果GPU加速型实例已安装GPU驱动,需要先卸载原驱动后再安装新的目标驱动。

    GPU驱动自动安装脚本提供卸载驱动的能力,请在执行脚本时根据交互式界面按需选择。

  • GPU驱动安装成功后,实例会自动重启。
  • 仅部分Linux公共镜像支持通过脚本自动安装GPU驱动,如下所示:
    • CentOS 7.6、CentOS 7.9、CentOS 8.2。
    • Ubuntu 18.04、Ubuntu 20.04、Ubuntu22.04。

    如果在支持的Linux公共镜像中没有您需要的操作系统及版本,请参考GPU加速型实例安装Tesla驱动及CUDA工具包,手动安装GPU驱动。

  • 如果您使用的是私有镜像,请确保镜像已安装了Cloud-init组件及安装GPU驱动所需的依赖,且需使用驱动脚本所支持的Linux操作系统及版本。
  • 请根据表1选择需要的驱动安装包版本。
    表1 支持的GPU驱动版本

    CUDA软件版本

    Driver软件版本

    CuDNN软件版本

    10.2

    440.118.02

    8.0.5

    11.0

    450.191.01

    8.1.1

    11.2

    460.73.01

    8.1.1

    11.4

    470.103.01

    8.2.4

驱动安装脚本支持区域及获取方式

您可以通过执行以下命令,获取驱动安装脚本。

  • 华北-北京一
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-north-1.obs.cn-north-1.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华北-北京二
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-north-2.obs.cn-north-2.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华北-北京四
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-north-4.obs.cn-north-4.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华北-乌兰察布一
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-north-9.obs.cn-north-9.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华东-上海一
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-east-3.obs.cn-east-3.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华东-上海二
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-east-2.obs.cn-east-2.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华南-广州
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-south-1.obs.cn-south-1.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 华南-广州-友好用户环境
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-south-4.obs.cn-south-4.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 西南-贵阳一
    wget -t 10 --timeout=10 https://hgcs-drivers-cn-southwest-2.obs.cn-southwest-2.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 中国-香港
    wget -t 10 --timeout=10 https://hgcs-drivers-ap-southeast-1.obs.ap-southeast-1.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 亚太-曼谷
    wget -t 10 --timeout=10 https://hgcs-drivers-ap-southeast-2.obs.ap-southeast-2.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 亚太-新加坡
    wget -t 10 --timeout=10 https://hgcs-drivers-ap-southeast-3.obs.ap-southeast-3.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh
  • 非洲-约翰内斯堡
    wget -t 10 --timeout=10 https://hgcs-drivers-af-south-1.obs.af-south-1.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh

操作步骤

以下操作以Ubuntu 20.04 64bit操作系统,P2v规格的GPU加速型实例安装CUDA 11.0对应的Tesla驱动为例进行介绍。

  1. 以root账号远程登录云服务器。
  2. 执行以下命令,获取驱动安装脚本并运行。

    wget -t 10 --timeout=10 https://hgcs-drivers-cn-east-2.obs.cn-east-2.myhuaweicloud.com/release/script/auto_install.sh && bash auto_install.sh

  3. 根据界面提示,选择需要安装的驱动版本。
    图1 选择驱动安装版本
  4. 卸载已安装驱动。

    如果云服务器已安装过驱动,请根据提示先执行驱动卸载操作。

    如果云服务器本身未安装驱动,脚本会自动跳过该步骤,开始进行驱动安装。

    1. 卸载CUDA Toolkit。
      图2 卸载CUDA Toolkit(1)
      图3 卸载CUDA Toolkit(2)
    2. 卸载GPU driver。
      图4 卸载GPU driver

    卸载完成后,开始安装驱动,此过程会持续几分钟,请耐心等待。

  5. 驱动安装完成后,会自动重启云服务器后,请重新以root账号登录。
  1. 执行以下命令,检查驱动是否安装成功。

    nvidia-smi

    如果返回信息中包含了已安装的驱动版本,说明驱动安装成功。

    图5 查看驱动安装结果
  2. 执行以下命令,检查CUDA版本是否正确。

    /usr/local/cuda/bin/nvcc -V

    图6 检查CUDA版本
  3. (可选)检查CUDA是否正常。
    1. 执行以下命令,进入“/usr/local/cuda/samples/1_Utilities/deviceQuery”目录。

      cd /usr/local/cuda/samples/1_Utilities/deviceQuery

    2. 执行以下命令,自动编译deviceQuery程序。

      make

    3. 执行以下命令,查看CUDA是否安装成功。

      ./deviceQuery

      如果返回信息中有CUDA的版本信息,则表明CUDA安装成功。

      图7 查看CUDA安装结果
分享:

    相关文档

    相关产品