Help Center/ Elastic Cloud Server/ User Guide (Ankara Region)/ Instances/ Managing GPU Drivers of GPU-accelerated ECSs/ Installing a Tesla Driver and CUDA Toolkit on a GPU-accelerated ECS
Updated on 2024-07-24 GMT+08:00

Installing a Tesla Driver and CUDA Toolkit on a GPU-accelerated ECS

Scenarios

Before using a GPU-accelerated ECS, make sure that the desired Tesla driver and CUDA toolkit have been installed on the ECS for computing acceleration.

  • A computing-accelerated (P series) ECS created using a public image has had a Tesla driver of a specified version installed by default.
  • After a GPU-accelerated ECS is created using a private image, it must have a Tesla driver installed. Otherwise, computing acceleration will not take effect.

This section describes how to install a Tesla driver and CUDA toolkit on a GPU-accelerated ECS.

Notes

  • The ECS must have an EIP bound.
  • Check whether the CUDA toolkit and Tesla driver have been installed on the ECS.
  • If the CUDA toolkit has not been installed, download it from the official NVIDIA website and install it. A Tesla driver matching the CUDA version will be automatically installed then. However, if there are specific requirements or dependencies on the Tesla driver version, download the matching Tesla driver from the official NVIDIA website first and then install the driver before installing the CUDA toolkit.
  • If a Tesla driver has been installed on the ECS, check the driver version. Before installing a new driver version, uninstall the original Tesla driver to prevent an installation failure due to driver conflicts.

Installing a Tesla Driver on a Linux ECS

The following uses Ubuntu 16.04 64bit as an example to describe how to install the Tesla driver matching CUDA 10.1 on a GPU-accelerated ECS.

The Linux kernel version is compatible with the driver version. If installing the driver failed, check the driver installation log, which is generally stored in /var/log/nvidia-installer.log. If the log shows that the failure was caused by a driver compilation error, for example, the get_user_pages parameter setting is incorrect, the kernel version is incompatible with the driver version. In such a case, select the desired kernel version and driver version and reinstall them. It is recommended that the release time of the kernel version and driver version be the same.

  1. Log in to the ECS.
  2. Update the system software based on the OS.
    • Ubuntu

      Update the software installation source: apt-get -y update

      Install necessary programs: apt-get install gcc g++ make

    • CentOS

      Update the software installation source: yum -y update --exclude=kernel* --exclude=centos-release* --exclude=initscripts*

      Install the desired program: yum install -y kernel-devel-`uname -r` gcc gcc-c++

  3. Download the NVIDIA driver package.

    Select a driver version at NVIDIA Driver Downloads based on the ECS type. Click SEARCH.

    Figure 1 Selecting a NVIDIA driver version
  4. Select a driver version as required. The following uses Tesla 418.67 as an example.
    Figure 2 Selecting a driver version
  5. Click the driver to be downloaded. On the TESLA DRIVER FOR LINUX X64 page that is displayed, click DOWNLOAD.
  6. Copy the download link.
    Figure 3 Copying the download link
  7. Run the following command on the ECS to download the driver:

    wget Copied link

    For example, wget http://us.download.nvidia.com/tesla/418.67/NVIDIA-Linux-x86_64-418.67.run

    Figure 4 Obtaining the installation package
  8. Run the following command to install the driver:

    sh NVIDIA-Linux-x86_64-418.67.run

  9. (Optional) If the following information is displayed after the command for installing the driver is executed, disable the Nouveau driver.
    Figure 5 Disabling the Nouveau driver
    1. Run the following command to check whether the Nouveau driver has been installed:

      lsmod | grep nouveau

      • If the command output contains information about the Nouveau driver, the Nouveau driver has been installed and must be disabled. Then, go to step 9.b.
      • If the command output does not contain information about the Nouveau driver, the Nouveau driver has been disabled. Then, go to step 10.
    2. Edit the blacklist.conf file.

      If the /etc/modprobe.d/blacklist.conf file is unavailable, create it.

      vi /etc/modprobe.d/blacklist.conf

      Add the following statement to the end of the file:

      blacklist nouveau
      options nouveau modeset=0
    1. Run the following command to back up and create an initramfs application:
      • Ubuntu

        sudo update-initramfs -u

      • CentOS:

        mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

        dracut -v /boot/initramfs-$(uname -r).img $(uname -r)

    1. Restart the ECS:

      reboot

  10. Select OK for three consecutive times as prompted to complete the driver installation.
    Figure 6 Completing the NVIDIA driver installation
  11. Run the following command to set systemd:

    systemctl set-default multi-user.target

  12. Run the reboot command to restart the ECS.
  13. Log in to the ECS and run the nvidia-smi command. If the command output contains the installed driver version, the driver has been installed.
    Figure 7 Viewing the NVIDIA driver version

Installing a Tesla Driver on a Windows ECS

The following uses Windows Server 2016 Standard 64bit as an example to describe how to install a Tesla driver on a GPU-accelerated ECS.

  1. Log in to the ECS.
  2. Download the NVIDIA driver package.

    Select a driver version at NVIDIA Driver Downloads based on the ECS type.

    Figure 8 Selecting a driver type (Windows)
  3. Select a driver version as required. The following uses Tesla 425.25 as an example.
    Figure 9 Selecting a driver version (Windows)
  4. Click the driver to be downloaded. On the TESLA DRIVER FOR WINDOWS page that is displayed, click DOWNLOAD.
  5. Click AGREE & DOWNLOAD to download the installation package.
    Figure 10 Downloading the driver installation package
  6. Double-click the driver and click Run.
    Figure 11 Running the NVIDIA driver installation program
  7. Select an installation path and click OK.
    Figure 12 Selecting an installation path
  8. Install the NVIDIA program as prompted.
    Figure 13 Completing the driver installation
  9. Restart the ECS.
  10. Check whether the NVIDIA driver has been installed.
    1. Switch to Device Manager and click Display adapters.
      Figure 14 Display adapters
    1. Open the cmd window on the ECS and run the following commands:

      cd C:\Program Files\NVIDIA Corporation\NVSMI

      nvidia-smi

      If the command output contains the installed driver version, the driver has been installed.

      Figure 15 Viewing the NVIDIA driver version

Installing the CUDA Toolkit on a Linux ECS

The following uses Ubuntu 16.04 64bit as an example to describe how to install the CUDA 10.1 toolkit on a GPU-accelerated ECS.

  1. Log in to the ECS.
  2. Update the system software based on the OS.
    • Ubuntu

      Update the software installation source: apt-get -y update

      Install necessary programs: apt-get install gcc g++ make

    • CentOS

      Update the software installation source: yum -y update --exclude=kernel* --exclude=centos-release* --exclude=initscripts*

      Install the desired program: yum install -y kernel-devel-`uname -r` gcc gcc-c++

  3. On the CUDA download page, set parameters according to the information shown in Obtaining a Tesla Driver and CUDA Toolkit.
    Figure 16 Selecting a CUDA version
  4. Find the link for downloading CUDA 10.1 and copy the link.
    Figure 17 Copying the link for downloading CUDA
  1. Run the following command on the ECS to download CUDA:

    wget Copied link

    For example, wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run

    Figure 18 Downloading CUDA
  1. Install CUDA.
    Follow the instructions provided on the official NVIDIA website.
    Figure 19 Installing CUDA
  2. Run the following command to install CUDA:

    sh cuda_10.1.243_418.87.00_linux.run

  3. Select accept on the installation page and press Enter.
    Figure 20 Installing CUDA_1
  4. Select Install and press Enter to start the installation.
    Figure 21 Installing CUDA_2
    Figure 22 Completing the installation
  5. Run the following command to switch to /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery:

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

  6. Run the make command to automatically compile the deviceQuery program.
  7. Run the following command to check whether CUDA has been installed:

    ./deviceQuery

    If the command output contains the CUDA version, CUDA has been installed.

    Figure 23 deviceQuery common output
  8. Check the CUDA version.

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

    Figure 24 Checking the CUDA version
  9. Run the following command to enable the persistent mode:

    sudo nvidia-smi -pm 1

    Enabling the persistent mode optimizes the GPU performance on Linux ECSs.

Installing the CUDA Toolkit on a Windows ECS

The following uses Windows Server 2016 Standard 64bit as an example to describe how to install the CUDA 10.1 toolkit on a GPU-accelerated ECS.

  1. Log in to the ECS.
  2. On the CUDA download page, set parameters according to the information shown in Downloading a CUDA Toolkit.
    Figure 25 Selecting a CUDA version
  3. Find the link for downloading CUDA 10.1.
    Figure 26 Finding the link for downloading CUDA
  4. Click Download to download the CUDA toolkit.
  5. Double-click the installation file and click Run to install the CUDA toolkit.
    Figure 27 Installing CUDA
  6. On the CUDA Setup Package page, select an installation path and click OK.
    Figure 28 Selecting an installation path
  7. Install the CUDA toolkit as prompted.
    Figure 29 Completing the installation
  1. Check whether CUDA has been installed

    Open the cmd window and run the following command:

    nvcc -V

    If the command output contains the CUDA version, CUDA has been installed.

    Figure 30 Successful installation