GPU-accelerated graphical desktop on Ubuntu Linux with NVIDIA GRID and Amazon DCV
Setup a GPU-accelerated workstation on Ubuntu that supports up to four 4K displays and audio playback
Overview
This article describes how to setup a GPU-accelerated graphical desktop on Amazon EC2 instance running Ubuntu Linux with NVIDIA GRID driver, and access it using Amazon DCV high performance remote desktop protocol.
This article applies to Ubuntu on AWS only. Similar articles are available for AL2023 and Windows.
The article installs NVIDIA GRID driver which supports most G instance types. To install NVIDIA Tesla GPU driver, refer to Install NVIDIA GPU driver, CUDA Toolkit, NVIDIA Container Toolkit on Amazon EC2 instances running Ubuntu Linux.
Other install options
- Consider managed EUC (End User Computing) services such as Amazon WorkSpaces
- Use this repository CloudFormation templates to automate setup on AL2023, Ubuntu, Windows or other OSs
- Setup Deep Learning workstation with AWS Deep Learning AMIs
- Install NVIDIA Tesla driver and graphical desktop
- Install desktop environment, NVIDIA GRID driver and Amazon DCV Server from documentation
- Amazon Machine Images (AMIs) with NVIDIA GRID drivers installed are available from AWS MarketPlace
Prerequisites
Verify that the On-Demand Instance quota value for Running On-Demand G and VT instances in your desired AWS Region is equal or greater than your desired instance size vCPUs count. Request a quota increase if otherwise.
Do not proceed until your applied quota value is equal or higher than your desired instance type vCPUs count
Launch EC2 instance
Launch a new EC2 instance with the following attributes
- Ubuntu Server 24.04 LTS or 22.04 LTS
G7e, G6, G6e, G6f, Gr6, Gr6f, G5 or G4dnEC2 instance type- Security group that allows inbound TCP and UDP port
8443from your IP - More than 15 GB EBS volume size
- EC2 IAM role with AmazonS3ReadOnlyAccess managed policy attached for DCV license validation
Connect to the instance as ubuntu
Installation
Run the below commands
Install DKMS and kernel headers
sudo apt update sudo apt upgrade -y sudo apt autoremove -y sudo apt install -y dkms linux-headers-aws linux-modules-extra-aws unzip gcc make libglvnd-dev pkg-config sudo apt install -y mesa-utils vulkan-tools clinfo amazon-ec2-utils sudo tee /etc/modprobe.d/blacklist.conf > /dev/null << EOF blacklist vga16fb blacklist nouveau blacklist rivafb blacklist nvidiafb blacklist rivatv EOF sudo sed -i "s/^GRUB_CMDLINE_LINUX=\"/&rdblacklist=nouveau/" /etc/default/grub sudo update-grub
Restart your EC2 instance
sudo reboot
Install GNOME desktop and Amazon DCV server
sudo apt update sudo apt install -y ubuntu-desktop-minimal sudo sed -i '/^\[daemon\]/a WaylandEnable=false' /etc/gdm3/custom.conf sudo systemctl set-default graphical.target sudo sed -i "s/Prompt=lts/Prompt=never/g" /etc/update-manager/release-upgrades cd /tmp OS_VERSION=$(. /etc/os-release;echo $VERSION_ID | sed -e 's/\.//g') curl -L -O https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-ubuntu$OS_VERSION-$(arch).tgz tar -xvzf nice-dcv-ubuntu$OS_VERSION-$(arch).tgz && cd nice-dcv-*-$(arch) sudo apt install -y ./nice-dcv-server_*.deb sudo apt install -y ./nice-dcv-web-viewer_*.deb sudo apt install -y ./nice-xdcv_*.deb sudo apt install -y ./nice-dcv-gltest_*.deb sudo usermod -aG video dcv sudo systemctl enable dcvserver USER=ubuntu sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"$USER\"\nstorage-root=\"%home%\"" /etc/dcv/dcv.conf sudo sed -i "s/^#create-session/create-session/g" /etc/dcv/dcv.conf sudo apt install -y cups sudo usermod -a -G lpadmin dcv sudo systemctl enable --now cups
Use of DCV is subject to DCV EULA (end user license agreement)
Install NVIDIA GRID driver
We will install NVIDIA GRID (also known as NVIDIA RTX Virtual Workstation (vWS)) driver. NVIDIA GRID drivers are certified to provide optimal performance for professional visualization applications that render content such as 3D models or high-resolution videos, and provide access to four 4K displays per GPU.
cd /tmp if (lsb_release -r -s | grep -q 22); then if (cat /proc/version | grep -q gcc-12); then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 sudo update-alternatives --config gcc fi fi sudo snap install aws-cli --classic aws s3 cp --recursive s3://ec2-linux-nvidia-drivers/latest/ . --no-sign-request chmod +x NVIDIA-Linux-x86_64*.run sudo ./NVIDIA-Linux-x86_64*.run -s --skip-module-load echo "options nvidia NVreg_EnableGpuFirmware=0" | sudo tee --append /etc/modprobe.d/nvidia.conf sudo modprobe nvidia nvidia-smi sudo nvidia-xconfig --enable-all-gpus --connected-monitor=DFP-0,DFP-1,DFP-2,DFP-3
Note that NVIDIA GRID driver is available for AWS customers only. By downloading and installing the software, you are bound by the terms of the NVIDIA GRID Cloud EULA (End User License Agreement).
Configure password
Configure a strong ubuntu password
sudo passwd ubuntu
Start X Windows and DCV server
sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target sudo systemctl restart dcvserver
Alternatively, restart your EC2 instance.
Optional: GPU-accelerated container workloads
Besides GPU-accelerated graphics, you may want to run GPU-accelerated container workloads.
Install Docker and NVIDIA Container Toolkit
DISTRO=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g') curl -L -O https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/x86_64/cuda-keyring_1.1-1_all.deb sudo apt install -y ./cuda-keyring_1.1-1_all.deb sudo apt update sudo apt install -y docker.io sudo usermod -aG docker ubuntu sudo systemctl enable docker sudo apt update sudo apt install -y nvidia-container-toolkit sudo nvidia-ctk runtime configure --runtime=docker sudo systemctl restart docker
Refer to Install NVIDIA GPU driver, CUDA Toolkit, NVIDIA Container Toolkit on Amazon EC2 instances running Ubuntu Linux for more details including CUDA toolkit and other NVIDIA software installation.
Connect to Ubuntu using DCV client
Download and install native client from https://www.amazondcv.com/.
Connect your macOS , Windows or Linux client to EC2 instance public IP address. Login as ubuntu.
While you can connect using web browser client, native clients provide better user experience with additional features such as QUIC UDP transport protocol, multi-channel audio, and up to four 4K displays support.
Using Amazon DCV
Refer to DCV User Guide for usage guidance, e.g. transferring files.
EC2 Install Script
You can use the below as install script (or user data) to install NVIDIA GRID driver, docker with NVIDIA Container Toolkit, and Amazon DCV server on a new Ubuntu 24.04 or 22.04 GPU instance preferably with latest updates applied and with at least 15 GB storage.
#!/bin/bash export DEBIAN_FRONTEND=noninteractive sudo apt-get update sudo apt-get upgrade -y sudo apt-get autoremove -y sudo apt-get install -y dkms linux-headers-aws linux-headers-$(uname -r) linux-modules-extra-aws linux-modules-extra-$(uname -r) unzip gcc make libglvnd-dev pkg-config sudo apt-get install -y mesa-utils vulkan-tools clinfo amazon-ec2-utils sudo tee /etc/modprobe.d/blacklist.conf > /dev/null << EOF blacklist vga16fb blacklist nouveau blacklist rivafb blacklist nvidiafb blacklist rivatv EOF sudo sed -i "s/^GRUB_CMDLINE_LINUX=\"/&rdblacklist=nouveau/" /etc/default/grub sudo update-grub sudo apt-get install -y ubuntu-desktop-minimal sudo sed -i '/^\[daemon\]/a WaylandEnable=false' /etc/gdm3/custom.conf sudo systemctl set-default graphical.target sudo sed -i "s/Prompt=lts/Prompt=never/g" /etc/update-manager/release-upgrades cd /tmp OS_VERSION=$(. /etc/os-release;echo $VERSION_ID | sed -e 's/\.//g') curl -L -O https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-ubuntu$OS_VERSION-$(arch).tgz tar -xvzf nice-dcv-ubuntu$OS_VERSION-$(arch).tgz && cd nice-dcv-*-$(arch) sudo apt-get install -y ./nice-dcv-server_*.deb sudo apt-get install -y ./nice-dcv-web-viewer_*.deb sudo apt-get install -y ./nice-xdcv_*.deb sudo apt-get install -y ./nice-dcv-gltest_*.deb sudo usermod -aG video dcv sudo systemctl enable dcvserver USER=ubuntu sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"$USER\"\nstorage-root=\"%home%\"" /etc/dcv/dcv.conf sudo sed -i "s/^#create-session/create-session/g" /etc/dcv/dcv.conf sudo apt-get install -y cups sudo usermod -a -G lpadmin dcv sudo systemctl enable --now cups cd /tmp if (lsb_release -r -s | grep -q 22); then if (cat /proc/version | grep -q gcc-12); then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 sudo update-alternatives --config gcc fi fi sudo snap install aws-cli --classic aws s3 cp --recursive s3://ec2-linux-nvidia-drivers/latest/ . --no-sign-request chmod +x NVIDIA-Linux-x86_64*.run KERNEL_VERSION=$(ls -a /lib/modules | sort -V -r | head -n 1) if (! uname -r | grep -q $KERNEL_VERSION ); then sudo ./NVIDIA-Linux-x86_64*.run -s --kernel-source-path=/lib/modules/$KERNEL_VERSION/build --kernel-name=$KERNEL_VERSION --skip-module-load sudo dkms autoinstall else sudo ./NVIDIA-Linux-x86_64*.run -s --skip-module-load fi echo "options nvidia NVreg_EnableGpuFirmware=0" | sudo tee --append /etc/modprobe.d/nvidia.conf sudo modprobe nvidia nvidia-smi sudo nvidia-xconfig --enable-all-gpus --connected-monitor=DFP-0,DFP-1,DFP-2,DFP-3 sudo apt-get install -y docker.io sudo usermod -aG docker ubuntu sudo systemctl enable docker DISTRO=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g') curl -L -O https://developer.download.nvidia.com/compute/cuda/repos/$DISTRO/x86_64/cuda-keyring_1.1-1_all.deb sudo apt-get install -y ./cuda-keyring_1.1-1_all.deb sudo apt-get update sudo apt-get install -y nvidia-container-toolkit sudo nvidia-ctk runtime configure --runtime=docker sudo systemctl restart docker sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target sudo systemctl restart dcvserver sudo reboot
Do set ubuntu user password before using.
- Topics
- Compute
- Language
- English
Relevant content
- Accepted Answerasked 9 months ago
