Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

Installing the NVIDIA Driver on Linux Instances

A GPU-based accelerated computing instance must have the appropriate NVIDIA driver. The NVIDIA driver that you install must be compiled against the kernel that you plan to run on your instance.

Amazon provides AMIs with updated and compatible builds of the NVIDIA kernel drivers for each official kernel upgrade in the AWS Marketplace. If you decide to use a different NVIDIA driver version than the one that Amazon provides, or decide to use a kernel that's not an official Amazon build, you must uninstall the Amazon-provided NVIDIA packages from your system to avoid conflicts with the versions of the drivers that you are trying to install.

Use this command to uninstall Amazon-provided NVIDIA packages:

sudo yum erase nvidia cuda

The Amazon-provided CUDA toolkit package has dependencies on the NVIDIA drivers. Uninstalling the NVIDIA packages erases the CUDA toolkit. You must reinstall the CUDA toolkit after installing the NVIDIA driver.

Downloading the NVIDIA GRID Driver (G3)

For G3 instances, you can download the NVIDIA GRID driver from Amazon S3 using the AWS CLI or SDKs. To install the AWS CLI, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide.

Important

This download is available to AWS customers only. By downloading, you agree to use the downloaded software only to develop AMIs for use with the NVIDIA Tesla M60 hardware. Upon installation of the software, you are bound by the terms of the NVIDIA GRID Cloud End User License Agreement.

Use the following AWS CLI command to download the driver:

aws s3 cp --recursive s3://ec2-linux-nvidia-drivers/ .

If you receive an Unable to locate credentials error, the AWS CLI on the instance is not configured to use your AWS credentials. To configure the AWS CLI to use your AWS credentials, see Quick Configuration in the AWS Command Line Interface User Guide.

Downloading a Public NVIDIA Driver (G2, P2, P3)

For instance types other than G3, or if you are not using NVIDIA GRID functionality on a G3 instance, you can download the public NVIDIA drivers.

Download the 64-bit NVIDIA driver appropriate for your instance type from http://www.nvidia.com/Download/Find.aspx.

Instances Product Type Product Series Product
G2 GRID GRID Series GRID K520
P2 Tesla K-Series K-80
P3 Tesla V-Series V100

For more information about installing and configuring the driver, choose the ADDITIONAL INFORMATION tab on the download page for the driver on the NVIDIA website and choose the README link.

Installing the NVIDIA Driver Manually

To install the driver on a Linux instance

  1. Update your package cache and get necessary package updates for your instance.

    • For Amazon Linux, CentOS, and Red Hat Enterprise Linux:

      sudo yum update -y
    • For Ubuntu and Debian:

      sudo apt-get update -y
  2. (Ubuntu 16.04 and later, with the linux-aws package) Upgrade the linux-aws package to receive the latest version.

    sudo apt-get upgrade -y linux-aws
  3. Reboot your instance to load the latest kernel version.

    sudo reboot
  4. Reconnect to your instance after it has rebooted.

  5. Install the gcc compiler and the kernel headers package for the version of the kernel you are currently running.

    • For Amazon Linux, CentOS, and Red Hat Enterprise Linux:

      sudo yum install -y gcc kernel-devel-$(uname -r)
    • For Ubuntu and Debian:

      sudo apt-get install -y gcc make linux-headers-$(uname -r)
  6. (Graphical desktop instances only) Disable the nouveau open source driver for NVIDIA graphics cards.

    1. Add nouveau to the /etc/modprobe.d/blacklist.conf blacklist file. Copy the following code block and paste it into a terminal.

      cat << EOF | sudo tee --append /etc/modprobe.d/blacklist.conf blacklist vga16fb blacklist nouveau blacklist rivafb blacklist nvidiafb blacklist rivatv EOF
    2. Edit the /etc/default/grub file and add the following line:

      GRUB_CMDLINE_LINUX="rdblacklist=nouveau"
    3. Rebuild the Grub configuration.

      • CentOS and Red Hat Enterprise Linux:

        sudo grub2-mkconfig -o /boot/grub2/grub.cfg
      • For Ubuntu and Debian:

        sudo update-grub
  7. Download the driver package that you identified earlier as follows.

    • For P2 and P3 instances, the following command downloads the NVIDIA driver, where xxx.xxx represents the version of the NVIDIA driver.

      wget http://us.download.nvidia.com/tesla/xxx.xxx/NVIDIA-Linux-x86_64-xxx.xxx.run
    • For G2 instances, the following command downloads the NVIDIA driver, where xxx.xxx represents the version of the NVIDIA driver.

      wget http://us.download.nvidia.com/XFree86/Linux-x86_64/xxx.xxx/NVIDIA-Linux-x86_64-xxx.xxx.run
    • For G3 instances, you can download the driver from Amazon S3 using the AWS CLI or SDKs. To install the AWS CLI, see Installing the AWS Command Line Interface in the AWS Command Line Interface User Guide. Use the following AWS CLI command to download the driver and the NVIDIA GRID Cloud End User License Agreement:

      aws s3 cp --recursive s3://ec2-linux-nvidia-drivers/ .

      Important

      This download is available to AWS customers only. By downloading, you agree to use the downloaded software only to develop AMIs for use with the NVIDIA Tesla M60 hardware. Upon installation of the software, you are bound by the terms of the NVIDIA GRID Cloud End User License Agreement.

  8. Run the self-install script to install the NVIDIA driver that you downloaded in the previous step. For example:

    sudo /bin/bash ./NVIDIA-Linux-x86_64-xxx.xxx.run

    When prompted, accept the license agreement and specify the installation options as required (you can accept the default options).

  9. Reboot the instance.

    sudo reboot
  10. Confirm that the driver is functional. The response for the following command lists the installed NVIDIA driver version and details about the GPUs.

    Note

    This command may take several minutes to run.

    nvidia-smi -q | head
  11. [G3 instances only] To enable NVIDIA GRID Virtual Workstation or NVIDIA GRID Virtual Applications on a G3 instance, complete the GRID activation steps in Activate NVIDIA GRID Capabilities (G3 Instances Only).

  12. [P2, P3, and G3 instances] Complete the optimization steps in Optimizing GPU Settings (P2, P3, and G3 Instances) to achieve the best performance from your GPU.