Skip to content

Deep Learning graphical desktop on Ubuntu Linux with AWS Deep Learning AMI (DLAMI)

7 minute read
Content level: Advanced
2

Setup a deep learning workstation running Ubuntu Linux based on Deep Learning AMI (DLAMI)

Overview

AWS Deep Learning AMIs (DLAMI) provides ML practitioners and researchers with a curated and secure set of frameworks, dependencies, and tools to accelerate deep learning (DL) on Amazon EC2. The GPU AMIs supports NVIDIA GPU instance types and are preinstalled with NVIDIA driver and software such as CUDA Toolkit, NCCL, cuDNN, Docker and NVIDIA Container Toolkit. Neuron Deep Learning AMIs supports Inferentia and Trainium instance types and are pre-installed with Neuron SDK. ƒnv This article suggest how you can create a DL graphical desktop EC2 instance running Ubuntu Linux that is based on DLAMI with Amazon DCV server for remote graphical access, and with GPU accelerated graphics (for NVIDIA GPU instance types). To build a Amazon Linux 2023 DL desktop, refer to this article.

For this article, we will use g4dn.xlarge to launch Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Ubuntu 22.04) AMI in us-west-2 (Oregon) Region.

Notice

Your use of DCV is subject to DCV End User License Agreement (EULA).

Prerequisites

DLAMI release notes

  • For the desired AMI, view release notes details. Note the following values

    • AMI name : e.g. Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Ubuntu 22.04)
    • Supported EC2 instances : e.g. G4dn, G5, G6, Gr6, G6e, P4, P4de, P5, P5e, P5en, P6-B200
  • Go to Amazon EC2 instance types by Region. Determine what supported EC2 instance types are available in your AWS Region in Accelerated Computing section

EC2 instance types by Region

  • Go to EC2 console of your desired Region, Instance types. Filter by your instance type family, e.g. g4dn

EC2 instance types

Service Quota

Request quota increase if the assigned value is less than vCPU count of your desired EC2 instance size. Do not proceed until your applied quota value is equal or higher than your instance type vCPUs count

Prepare Ubuntu Linux

Go to EC2 console to launch EC2 instance. Search for and select your DLAMI. You can search by AMI name, e.g. Deep Learning OSS Nvidia Driver AMI GPU PyTorch.

DLAMI search

You may have to search Community AMIs section. Some Regions may not support DLAMI.

DLAMI search community

Ensure the following

{
    "Version": "2012-10-17",
    "Statement": [
       {
           "Effect": "Allow",
           "Action": "s3:GetObject",
           "Resource": "arn:aws:s3:::dcv-license.REGION/*"
       }
    ]
}

Connect to your instance as ubuntu

Set user password

Specify a strong password for ubuntu

sudo passwd ubuntu

Install graphical desktop and Amazon DCV

Run the following script to install graphical desktop environment and Amazon DCV server. Script will restart your instance upon completion

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 GPU instance types

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
sudo apt update
sudo apt install -y amazon-ec2-utils
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
if (arch | grep -q x86); then
  sudo apt install -y ./nice-dcv-gltest_*.deb
fi
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

DLAMI=$(grep -rl "Deep Learning" /etc/update-motd.d/*)
mkdir -p /home/ubuntu/Desktop
. $DLAMI > /home/ubuntu/Desktop/README.md

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
  sudo systemctl enable --now dlami-cloudwatch-agent@partial
fi

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

sudo reboot

Access graphical desktop environment

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

Using Amazon DCV

Refer to DCV User Guide for usage guidance, e.g. transferring files.

DLAMI notes

DLAMI notes can be located at /home/ubuntu/Desktop/README.md

NVIDIA graphics acceleration

If you are using a NVIDIA GPU instance type, run the following command to verify that X Windows is using GPU for graphics acceleration

nvidia-smi

Verify that nvidia-smi Processes list output includes Xorg (for graphical desktop acceleration). To verify Vulkan and OpenGL GPU acceleration, you can run vkcube and dcvgltest (x86_64 only) and check nvidia-smi process listing.

Ubuntu Deep Learning Desktop

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

NVIDIA driver type

DLAMI uses Tesla (also know as NVIDIA Data Center GPU) driver which support one display of up to 2560x1600 resolution. GRID drivers provide access to four 4K displays per GPU and are certified to provide optimal performance for professional visualization applications. To setup a DL workstation with GRID driver, you can refer to documentation or article GPU-accelerated graphical desktop on Ubuntu Linux with NVIDIA GRID and Amazon DCV

Documentation

Refer to DLAMI Developer Guide/Neuron SDK and Amazon DCV User Guide for usage guidance

Other install options