Installing the NVIDIA driver on an AWS EC2 instance running Ubuntu 24.04 can sometimes be challenging due to AWS’s custom environment and kernel. Although the ubuntu-drivers
tool is the recommended way to install drivers on Ubuntu, we strongly recommend using apt
to install NVIDIA drivers on AWS EC2 instances to ensure compatibility and a more reliable setup.
Step 1: Use apt
to Install the NVIDIA Driver Directly
On AWS, using apt
to install the NVIDIA driver is more effective than the default ubuntu-drivers
approach, which may only install partial NVIDIA components. Installing the full driver package directly helps ensure all necessary components are in place.
To install the NVIDIA driver using apt
, run:
sudo apt update sudo apt install -y nvidia-driver-535-server
The -y
flag automatically accepts any prompts during installation. The nvidia-driver-535-server
package installs the complete server driver, including essential components like the Dynamic Kernel Module Support (DKMS), which ensures compatibility with AWS’s custom kernel.
Why Not Use ubuntu-drivers?
Using sudo ubuntu-drivers install --gpgpu
might seem convenient, but on AWS, this method often only installs partial packages like nvidia-headless
without the full driver, which can prevent the GPU from functioning correctly. To avoid these issues, we recommend directly installing the full driver package with apt
, as shown above.
Step 2: Check Installed NVIDIA Packages
After installation, verify the installed NVIDIA packages with:
dpkg -l | grep nvidia
You should see a list of installed packages similar to the following:
ubuntu@ip-10-138-2-148:~$ dpkg -l | grep nvidia ii libnvidia-cfg1-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA binary OpenGL/GLX configuration library ii libnvidia-common-535-server 535.216.01-0ubuntu0.24.04.1 all Shared files used by the NVIDIA libraries ii libnvidia-compute-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA libcompute package ii libnvidia-decode-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA Video Decoding runtime libraries ii libnvidia-egl-wayland1:amd64 1:1.1.13-1build1 amd64 Wayland EGL External Platform library -- shared library ii libnvidia-encode-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVENC Video Encoding runtime library ii libnvidia-extra-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 Extra libraries for the NVIDIA Server Driver ii libnvidia-fbc1-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA OpenGL-based Framebuffer Capture runtime library ii libnvidia-gl-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD ii nvidia-compute-utils-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA compute utilities ii nvidia-dkms-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA DKMS package ii nvidia-driver-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA Server Driver metapackage ii nvidia-firmware-535-server-535.216.01 535.216.01-0ubuntu0.24.04.1 amd64 Firmware files used by the kernel module ii nvidia-kernel-common-535-server 535.216.01-0ubuntu0.24.04.1 amd64 Shared files used with the kernel module ii nvidia-kernel-source-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA kernel source package ii nvidia-utils-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA Server Driver support binaries ii xserver-xorg-video-nvidia-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA binary Xorg driver
These packages provide all necessary GPU functionalities, including compute support, kernel module management (DKMS), and utilities (nvidia-utils-535-server) for interacting with the GPU, including nvidia-smi.
Step 3: Reboot and Verify the Installation
After installing the driver, reboot your instance to apply changes:
sudo reboot
Once your instance is back online, check the NVIDIA driver status by running:
lsmod | grep nvidia nvidia-smi
If the driver is correctly installed and functioning, nvidia-smi
will display details about your NVIDIA GPU, including memory usage, processes, and the driver version.
Troubleshooting: Common Issues
If you encounter issues, try these troubleshooting steps:
- Driver/Library Version Mismatch: If
nvidia-smi
shows a version mismatch, reinstall thenvidia-driver-535-server
package to ensure consistency. - NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running: Check whether necessary packages are installed and make sure kernel headers and other packages for the AWS kernel are installed:
ubuntu@ip-10-138-2-97:~$ dpkg -l | grep nvidia ii libnvidia-cfg1-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA binary OpenGL/GLX configuration library ii libnvidia-compute-535-server:amd64 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA libcompute package ii nvidia-compute-utils-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA compute utilities ii nvidia-firmware-535-server-535.216.01 535.216.01-0ubuntu0.24.04.1 amd64 Firmware files used by the kernel module ii nvidia-headless-no-dkms-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA headless metapackage - no DKMS ii nvidia-kernel-common-535-server 535.216.01-0ubuntu0.24.04.1 amd64 Shared files used with the kernel module ii nvidia-kernel-source-535-server 535.216.01-0ubuntu0.24.04.1 amd64 NVIDIA kernel source package sudo apt install nvidia-kernel-common-535 sudo apt install nvidia-dkms-535 sudo update-initramfs -u sudo apt install linux-headers-$(uname -r)
- Secure Boot: Secure Boot may block NVIDIA drivers. Disable Secure Boot in the BIOS if necessary.
Summary
For AWS EC2 instances, installing the NVIDIA driver using apt
is the most reliable method. The ubuntu-drivers
tool may not install all required components, particularly on AWS’s custom kernels. By following these steps, you can enable GPU capabilities on your AWS instance and make the most of NVIDIA-powered computations.
This guide should help you set up and verify the NVIDIA driver on your AWS Ubuntu 24.04 LTS instance using the recommended apt
method for AWS.
[…] For more detailed instructions, refer to the official NVIDIA driver installation guide for AWS Ubuntu. […]