Skip to content

Install GUI (graphical desktop) on Amazon EC2 instances running Ubuntu Linux

6 minute read
Content level: Intermediate
3

Steps to install desktop environment, desktop manager and Amazon DCV high performance remote display protocol server on Ubuntu Linux

Overview

This article suggests how you can install GUI (Graphical User Interface) on Amazon EC2 instances running Ubuntu Linux, and access it using Amazon DCV remote display protocol.

This article applies to Ubuntu Linux on AWS only. Similar articles are available for AL2, AL2023, RHEL/Rocky Linux and SLES 15

GPU instance

The following options are available if you are using NVIDIA GPU EC2 instance:

Notice

Your use of DCV is subject to DCV end user license agreement

Other options

Consider managed EUC (End User Computing) services such as Amazon WorkSpaces

Install prerequisites including desktop environment and Amazon DCV Server from Amazon DCV Administrator Guide

To quickly get up and running with DCV for internal testing, you can use CloudFormation template at DCV CloudFormation page. You can also explore amazon-ec2-nice-dcv-samples CloudFormation templates to provision your own EC2 instances with graphical desktop environment, DCV server and other features such as custom resolution, multi-monitor support and GPU driver installation.

AMIs preconfigured with graphical desktop environment are available from AWS Marketplace.

Requirements

Supported Ubuntu versions

The following versions are supported by Amazon DCV server

  • Ubuntu 24.04 (x86_64 and arm64)
  • Ubuntu 22.04 (x86_64 and arm64)

EC2 instance prerequisites

  • EC2 instance with 2 GiB or more memory
  • Attached security group allows inbound TCP and UDP port 8443 from your IP
  • More than 3 GB free disk space to install graphical desktop components and DCV server
  • Attached EC2 IAM role with the below policy for license validation. Replace REGION with your instance AWS Region code. Alternatively, attach AmazonS3ReadOnlyAccess managed policy.
{
    "Version": "2012-10-17",
    "Statement": [
       {
           "Effect": "Allow",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::dcv-license.REGION/*"
       }
    ]
}

Installing DCV

Install desktop environment and desktop manager

Install GNOME desktop and disable Wayland protocol. Disable upgrade prompt to newer LTS release.

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

Install DCV server

Install DCV server, web client and virtual session support, and enable server daemon

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 usermod -aG video dcv
sudo systemctl enable dcvserver

Console session XDummy driver

Install and configure XDummy driver. Run NVIDIA xorg.conf configurator if NVIDIA GPU desktop drivers are installed.

sudo apt install -y xserver-xorg-video-dummy
sudo tee /etc/X11/xorg.conf > /dev/null << EOF
Section "Device"
    Identifier "DummyDevice"
    Driver "dummy"
    Option "UseEDID" "false"
    VideoRam 512000
EndSection

Section "Monitor"
    Identifier "DummyMonitor"
    HorizSync   5.0 - 1000.0
    VertRefresh 5.0 - 200.0
    Option "ReducedBlanking"
EndSection

Section "Screen"
    Identifier "DummyScreen"
    Device "DummyDevice"
    Monitor "DummyMonitor"
    DefaultDepth 24
    SubSection "Display"
        Viewport 0 0
        Depth 24
        Virtual 4096 2160
    EndSubSection
EndSection
EOF

if [ -f /usr/bin/nvidia-xconfig ]; then
  sudo /usr/bin/nvidia-xconfig --preserve-busid --enable-all-gpus
  sudo apt install -y mesa-utils vulkan-tools clinfo
fi

Configure DCV server

Configure console session, file transfer and printing support

sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"ubuntu\"\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

Restart X server and DCV server

sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target
sudo systemctl stop dcvserver && sudo systemctl start dcvserver

Set user password

Specify a strong password for login user

sudo passwd ubuntu

Access graphical desktop environment

Clients

DCV offers Windows, Linux, macOS and web browser clients.

You can connect to DCV server using web browser client at https://<EC2-IP>:8443 (where <EC2-IP> is your EC2 instance IP address). Native clients provide better user experience and additional features, and can be downloaded from Amazon DCV site.

Login as ubuntu with your configured password

Do ensure that EC2 instance security group allow inbound TCP and UDP 8443 from your IP

Web browser client

Enter image description here

EC2 Install Script

You can use the below as install script (or user data) on a new Ubuntu Linux EC2 instance.

Comment out the line sudo /usr/bin/nvidia-xconfig --preserve-busid --enable-all-gpus if you do not want NVIDIA GPU accelerated graphics or intend to switch between instance types

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
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 usermod -aG video dcv
sudo systemctl enable dcvserver

sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"ubuntu\"\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

sudo apt install -y xserver-xorg-video-dummy
sudo tee /etc/X11/xorg.conf > /dev/null << EOF
Section "Device"
    Identifier "DummyDevice"
    Driver "dummy"
    Option "UseEDID" "false"
    VideoRam 512000
EndSection

Section "Monitor"
    Identifier "DummyMonitor"
    HorizSync   5.0 - 1000.0
    VertRefresh 5.0 - 200.0
    Option "ReducedBlanking"
EndSection

Section "Screen"
    Identifier "DummyScreen"
    Device "DummyDevice"
    Monitor "DummyMonitor"
    DefaultDepth 24
    SubSection "Display"
        Viewport 0 0
        Depth 24
        Virtual 4096 2160
    EndSubSection
EndSection
EOF

if [ -f /usr/bin/nvidia-xconfig ]; then
  sudo /usr/bin/nvidia-xconfig --preserve-busid --enable-all-gpus
  sudo apt install -y mesa-utils vulkan-tools clinfo
fi

sudo systemctl isolate multi-user.target && sudo systemctl isolate graphical.target
sudo systemctl stop dcvserver && sudo systemctl start dcvserver

Restart your EC2 instance and set ubuntu user password

Additional information

Refer to DCV documentation

DCV sessions

Amazon DCV on Linux offers two types of sessions: console sessions and virtual sessions. This article use console sessions, which has resolution limits especially on non GPU instances. Virtual sessions support custom resolution and multiple displays.

To switch to virtual session, connect to EC2 instance as ubuntu, disable console session, configure multi-user.target (optional) and reboot

sudo sed -i "s/^create-session/#create-session/g" /etc/dcv/dcv.conf
sudo systemctl restart dcvserver
sudo systemctl set-default multi-user.target
sudo systemctl isolate multi-user.target
sudo reboot

You will need to create a virtual session manually

/usr/bin/dcv create-session ubuntu --owner ubuntu --storage-root %home% --type virtual

To verify that virtual session has been created

dcv list-sessions

Output should be similiar to below

 Session: 'ubuntu' (owner:ubuntu type:virtual)

Refer to Using the command line on a Linux Amazon DCV Server for more information

AWS
EXPERT
published a year ago9.9K views
2 Comments

Hello @MikeLim

Thank you for your post, this is very helpful. I have a few questions.

It is practically impossible for me to get my corporate infra team to get the DCV port 8443(TCP & UDP)? Is this something that I can tunnel and use ssm to portforward and access through 443? Is it possible to have multiple users concurrently access their own Gnome sessions in a big fat ec2 instance?

Looking forward to your thoughts. Thank you! g

replied 9 months ago

Hi Govardhanen Gopal,

Thank you for the queries. SSM is designed for remote administration; and may not provide optimal experience for remote graphical access.

There are other solutions that allow graphical access from HTTPS port 443, and also multiple GNOME sessions. We do need to understand your use case in more detail. Can you reach out to your AWS account team? We can follow up from there. Thanks!

Mike

AWS
EXPERT
replied 9 months ago