Help Center> Elastic Cloud Server> User Guide> Instances> (Optional) Installing a Driver and Toolkit> Installing a NVIDIA GPU Driver and CUDA Toolkit (Recommended)

Installing a NVIDIA GPU Driver and CUDA Toolkit (Recommended)

Scenarios

When using a P1, P2v, or PI1 ECS, make sure that the GPU driver and CUDA toolkit have been installed on the ECS. Otherwise, computing acceleration will not take effect.

  • An ECS is available.
  • If the ECS is created using a public image, the GPU driver and CUDA toolkit have been installed by default.
  • If the ECS is created using a private image, check whether the GPU driver and CUDA toolkit have been installed. For details, see Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed.

    If the GPU driver and CUDA toolkit have not been installed on the target image, you can manually install them after the ECS is created. For details, see Installation Instructions.

Reading this section, you will learn:

  • How can I check whether the GPU driver and CUDA toolkit have been installed?
  • Have the GPU driver and CUDA toolkit been installed on an ECS?
  • How can I manually install the desired GPU driver and CUDA toolkit?

Notes

  • The operations described in this section apply only to P1, P2v, and PI1 ECSs.

Installation Instructions

  1. Check whether the GPU driver and CUDA toolkit have been installed on your ECS. For details, see Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed.

    • If they have been installed, no further action is required.
    • If no, go to 2.

  2. Install the GPU driver and CUDA toolkit.

    The installation method varies depending on the ECS OS. For details, see Table 1.

    Table 1 Instructions to install the GPU driver and CUDA toolkit

    OS

    Instruction

    Windows

    For details, see Installation Procedure for Windows.

    • CentOS 7.x
    • Red Hat Enterprise Linux (RHEL) 7.x
    • EulerOS 2.x

    For details, see Installation Procedure for CentOS 7.x, RHEL 7.x, and EulerOS 2.x.

    • CentOS 6.x
    • RHEL 6.x

    For details, see Installation Procedure for CentOS 6.x and RHEL 6.x.

    OpenSUSE 42.x

    For details, see Installation Procedure for OpenSUSE 42.x.

Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed

Perform the operations described in this section to check whether GPU driver and CUDA toolkit have been installed on an existing ECS. This method can also be used to check whether the installation of the GPU driver and CUDA toolkit is successful on an ECS with Automatically install GPU driver selected during the ECS creation.

  • Windows

    Check the C:\nvidia_install_log.txt file. If the installation failed, manually install the GPU driver and CUDA toolkit specified in the file.

  • Linux

    Check the /var/log/nvidia_install_log.txt file. If the installation failed, manually install the GPU driver and CUDA toolkit specified in the file.

Installation Procedure for Windows

  1. Download the GPU driver and CUDA toolkit installation packages required by the Windows ECS.

    URL: http://mirrors.myhuaweicloud.com/ecs/windows/exe/

    Visit the preceding URL on the ECS.

    In the preceding URL, there are three folders, win2008r2, win2012r2, and win2016. Each folder consists of the the cuda and driver installation packages.

    Obtain your desired installation packages according to the OS running on your ECS.

    An example is provided as follows:

    If your ECS runs Windows Server 2016, perform the following operations to obtain your desired GPU driver and CUDA toolkit:

    1. Visit http://mirrors.myhuaweicloud.com/ecs/windows/exe/.

      Visit the preceding URL on the ECS.

      The win2008r2, win2012r2, and win2016 folders are displayed.

    2. Open folder win2016.

      The cuda and driver folders are displayed.

    3. Select your desired GPU driver and CUDA toolkit versions.

      CUDA toolkit: cuda_9.0.176_windows.exe

      GPU driver: 385.08-tesla-desktop-winserver-international.exe

  2. Install the GPU driver and CUDA toolkit.

    Double-click .exe and install them as prompted.

Installation Procedure for CentOS 7.x, RHEL 7.x, and EulerOS 2.x

The operations described in this section apply to the ECSs running the following OSs:

  • CentOS 7.x series
  • Red Hat Enterprise Linux 7.x series
  • EulerOS 2.x series

For a Linux ECS, you are advised to use Repo for installation.

  1. Configure CUDA Repo for the CentOS 7.x, RHEL 7.x, or EulerOS 2.x ECS.

    1. (Optional) Run the following command to clear Repo files on the CentOS 7.x or EulerOS 2.x ECS:

      mv /etc/yum.repos.d/* /tmp/

    2. Run the following command to create a nvidia-centos7.repo file:

      vi /etc/yum.repos.d/nvidia-centos7.repo

    3. Add the following content to the file:
      [ecs-cuda] 
      name=ecs-cuda-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/cuda/7/$basearch 
      enabled=1
      gpgcheck=0
      [ecs-driver]
      name=ecs-driver-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/driver/7/$basearch
      enabled=1
      gpgcheck=0
      [ecs-package] 
      name=ecs-package-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/package/7/$basearch
      enabled=1
      gpgcheck=0
    4. Run the following command to install the desired Repo file:

      yum install http://mirrors.myhuaweicloud.com/epel/epel-release-latest-7.noarch.rpm -y

    5. Run the following command to clear useless Repo files:

      rm -rf epel-testing.repo

    6. Run the following command to update the epel-7 Repo file:

      curl -o /etc/yum.repos.d/epel.repo http://mirrors.myhuaweicloud.com/repo/epel-7.repo

    7. Update the Repo file on the CentOS ECS.
      • For the CentOS 7 system software repository

        curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-Base-7.repo

      • For the EulerOS system software repository

        curl -o /etc/yum.repos.d/EulerOS-Base.repo http://mirrors.myhuaweicloud.com/repo/euler/EulerOS_2_2_base.repo

        curl -o /etc/yum.repos.d/EulerOS-Base.repo http://mirrors.myhuaweicloud.com/repo/euler/EulerOS_2_3_base.repo

      • RHUI system software repository has been available for RHEL ECSs.

  2. Install CUDA on the CentOS 7.x, RHEL 7.x, or EulerOS 2.x ECS.

    1. Run the following command to install the kernel-devel that matches the kernel version:

      yum install -y kernel-devel-`uname -r`

    2. (Optional) For a CentOS ECS, run the following command to install DKMS:

      yum install -y dkms

    3. Run the following command to obtain the driver version:

      yum list | grep nvidia | grep driver | grep rhel7

    4. Run the following command to install the Repo file required by the driver version:

      yum install -y nvidia-diag-driver-local-repo-rhel7-*.x86_64

    5. Run the following command to install the driver:

      yum install -y cuda-drivers

    6. Run the following command to obtain the CUDA version:

      yum list | grep cuda | grep rhel7

      Figure 1 Obtaining the CUDA version
    7. Run the following command to install CUDA Repo:

      yum install -y cuda-repo-rhel*

      In the preceding command, * indicates the CUDA version obtained in 2.f. All the files in the target version must be installed.

    8. Run the following command to install CUDA:

      yum install -y cuda

    9. Run the following command to restart the ECS:

      reboot

Installation Procedure for CentOS 6.x and RHEL 6.x

The operations described in this section apply to the ECSs running the following OSs:

  • CentOS 6.x series
  • Red Hat Enterprise Linux 6.x series

For a Linux ECS, you are advised to use Repo for installation.

  1. Configure CUDA Repo for the CentOS 6.x or RHEL 6.x ECS.

    1. (Optional) Run the following command to clear Repo files on the CentOS 6.x ECS:

      mv /etc/yum.repos.d/* /tmp/

    2. Run the following command to create a nvidia-centos6.repo file:

      vi /etc/yum.repos.d/nvidia-centos6.repo

    3. Add the following content to the file:
      [ecs-cuda]
      name=ecs-cuda-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/cuda/6/$basearch
      enabled=1
      gpgcheck=0
      [ecs-driver] 
      name=ecs-driver-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/driver/6/$basearch
      enabled=1
      gpgcheck=0
      [ecs-package]
      name=ecs-package-$basearch
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/package/6/$basearch
      enabled=1
      gpgcheck=0
    4. Run the following command to install the desired Repo file:

      yum install http://mirrors.myhuaweicloud.com/epel/epel-release-latest-6.noarch.rpm -y

    5. Run the following command to clear useless Repo files:

      rm -rf epel-testing.repo

    6. Run the following command to update the epel-6 Repo file:

      curl -o /etc/yum.repos.d/epel.repo http://mirrors.myhuaweicloud.com/repo/epel-6.repo

    7. Update the Repo file on the CentOS ECS.
      • For the CentOS 6 system software repository

        curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-Base-6.repo

      • RHUI system software repository has been available for RHEL ECSs.

  2. Install CUDA on the CentOS 6.x or RHEL 6.x ECS.

    1. Run the following command to install the kernel-devel that matches the kernel version:

      yum install -y kernel-devel-`uname -r`

    2. Run the following command to obtain the driver version:

      yum list | grep nvidia | grep driver | grep rhel6

    3. Run the following command to obtain the Repo file version required by the driver:
      Figure 2 Obtaining the Repo file version
    4. Run the following command to install the desired Repo file version:

      yum install nvidia-diag-driver-local-repo-rhel6-*.x86_64

      In the preceding command, * indicates the Repo file version obtained in 2.c.

    5. Run the following command to install the driver:

      yum install -y cuda-drivers

    6. Run the following command to obtain the CUDA version:

      yum list | grep cuda | grep rhel6

      Figure 3 Obtaining the CUDA version
    7. Run the following command to install CUDA Repo:

      yum install cuda-repo-rhel*

      In the preceding command, * indicates the CUDA version obtained in 2.f. All the files in the target version must be installed.

    8. Run the following command to install CUDA:

      yum install -y cuda

    9. Run the following command to restart the ECS:

      reboot

Installation Procedure for Ubuntu 14.04 and Ubuntu 16.04

The operations described in this section apply to the ECSs running the following OSs:

  • Ubuntu 14.04
  • Ubuntu 16.04

For a Linux ECS, you are advised to use Repo for installation.

  1. Configure Repo on the Ubuntu 14.04 or Ubuntu 16.04 ECS.

    • Configure Repo on the Ubuntu 14.04 ECS.
      cp -fp /etc/apt/sources.list /etc/apt/sources.list.back 
      cat > /etc/apt/sources.list <<EOF 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-security main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-updates main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-proposed main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-backports main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-security main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-updates main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-proposed main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-backports main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs cuda 
      deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs driver 
      EOF 
      apt-get update --fix-missing
      wget -O - http://mirrors.myhuaweicloud.com/ecs/linux/apt/huaweicloud.ubuntu.gpg.key | apt-key add - 
      apt update
    • Configure Repo on the Ubuntu 16.04 ECS.
      cp -fp /etc/apt/sources.list /etc/apt/sources.list.back 
      cat > /etc/apt/sources.list <<EOF 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-security main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-updates main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-proposed main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-backports main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-security main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-updates main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-proposed main restricted universe multiverse 
      deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-backports main restricted universe multiverse 
      deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs cuda 
      deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs driver 
      EOF 
      apt-get update --fix-missing 
      wget -O - 
      http://mirrors.myhuaweicloud.com/ecs/linux/apt/huaweicloud.ubuntu.gpg.key | 
      apt-key add - 
      apt update

  2. Install CUDA on the Ubuntu 14.04 or Ubuntu 16.04 ECS.

    1. Run the following command to install the kernel-devel that matches the kernel version:

      apt-get install -y --allow-unauthenticated linux-headers-`uname -r`

    2. Run the following command to obtain the driver version:

      apt-cache search nvidia | grep driver | grep ubuntu

      Figure 4 Obtaining the driver version
    3. Run the following command to install the desired Repo file:

      apt-get install -y nvidia-diag-driver-local-repo-ubuntu*

      In the preceding command, * indicates the driver version obtained in 2.b. Only one specified version can be installed.

    4. Run the following command to install the driver:

      apt-get update && apt-get install -y --allow-unauthenticated cuda-drivers

    5. Run the following command to check the CUDA version:

      apt-cache search cuda | grep ubuntu

      Figure 5 Checking the CUDA version
    6. Run the following command to install the desired CUDA Repo file:

      apt-get install -y cuda-repo-ubuntu*

      In the preceding command, * indicates the driver version obtained in 2.g. All the files in the target version must be installed.

    7. Run the following command to install CUDA:

      pt-get update && apt-get install -y --allow-unauthenticated cuda

Installation Procedure for OpenSUSE 42.x

The operations described in this section apply to the ECSs running the following OSs:

  • OpenSUSE 42.x series
  1. Run the following command to configure the opensuse_source4202 system software repository:

    mv /etc/zypp/repos.d/* /tmp/ 
    sudo zypper ar -fcg 
    http://mirrors.myhuaweicloud.com/opensuse/distribution/leap/42.2/repo/oss 
    HWCloud:42.2:OSS 
    sudo zypper ar -fcg 
    http://mirrors.myhuaweicloud.com/opensuse/distribution/leap/42.2/repo/non-oss 
    HWCloud:42.3:NON-OSS 
    sudo zypper ar -fcg 
    http://mirrors.myhuaweicloud.com/opensuse/update/leap/42.2/oss 
    HWCloud:42.2:UPDATE-OSS 
    sudo zypper ar -fcg 
    http://mirrors.myhuaweicloud.com/opensuse/update/leap/42.2/non-oss 
    HWCloud:42.2:UPDATE-NON-OSS

  2. Configure CUDA Repo.

    1. Run the following command to create an HWnvidia-cudo.repo file:

      vi /etc/zypp/repos.d/HWnvidia-cudo.repo

    2. Add the following content to the file:
      [HWnvidia-cuda] 
      enabled=1 
      autorefresh=1 
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/zypper/opensuse422/cuda 
      type=rpm-md 
      gpgcheck=0
    3. Run the following command to create an HWnvidia-driver.repo file:
    4. Add the following content to the file:
      [HWnvidia-driver] 
      enabled=1 
      autorefresh=1 
      baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/zypper/opensuse422/driver 
      type=rpm-md 
      gpgcheck=0

  3. Install CUDA.

    1. Run the following command to install kernel-devel:

      zypper install -y kernel-default-devel=`uname -r|awk -F'-' '{print $1"-"$2}'`

    2. Run the following command to obtain the driver version:

      zypper se nvidia | grep driver | grep opensuse

      Figure 6 Obtaining the driver version
    3. Run the following command to install the desired driver Repo:

      zypper install -y nvidia-diag-driver-local-repo-opensuse422-*

    4. Run the following command to install the driver:

      zypper --gpg-auto-import-keys refresh && zypper install -y cuda-drivers

    5. Run the following command to check the CUDA version:

      zypper se cuda | grep opensuse

      Figure 7 Checking the CUDA version
    6. Run the following command to install the desired CUDA Repo file:

      zypper --no-gpg-checks install -y cuda-repo-opensuse*

      In the preceding command, * indicates the CUDA version.

    7. Run the following command to install CUDA:

      zypper --gpg-auto-import-keys refresh && zypper install -y cuda