Skip to content

Deep Learning graphical desktop on Amazon Linux 2023 (AL2023) with AWS Deep Learning AMI (DLAMI)

6 minute read
Content level: Advanced
2

Setup a deep learning workstation running Amazon Linux 2023 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.

This article suggest how you can create a DL graphical desktop EC2 instance running Amazon Linux 2023 that is based on DLAMI with Amazon DCV server for remote graphical access, and with GPU accelerated graphics (for NVIDIA GPU instance types). For Ubuntu Linux, refer to this article.

For this article, we will use g4dn.xlarge to launch Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Amazon Linux 2023) 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 (Amazon Linux 2023)
    • Supported EC2 instances : e.g. G4dn, G5, G6, Gr6, G6e, P4d, 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 Amazon Linux 2023

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 ec2-user

Set user password

Specify a strong password for ec2-user

sudo passwd ec2-user

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

#!/bin/bash
sudo dnf groupinstall "Desktop" -y
sudo sed -i '/^\[daemon\]/a WaylandEnable=false' /etc/gdm/custom.conf
sudo systemctl set-default graphical.target

cd /tmp
sudo rpm --import https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY
curl -L -O https://d1uj6qtbmh3dt5.cloudfront.net/nice-dcv-amzn2023-$(arch).tgz
tar -xvzf nice-dcv-amzn2023-$(arch).tgz && cd nice-dcv-*-amzn2023-$(arch)
sudo dnf install -y ./nice-dcv-server-*.rpm
sudo dnf install -y ./nice-dcv-web-viewer-*.rpm
sudo dnf install -y ./nice-xdcv-*.rpm
if (arch | grep -q x86); then
  sudo dnf install -y ./nice-dcv-gltest-*.rpm
fi
sudo systemctl enable dcvserver

sudo sed -i "/^\[session-management\/automatic-console-session/a owner=\"ec2-user\"\nstorage-root=\"%home%\"" /etc/dcv/dcv.conf
sudo sed -i "s/^#create-session/create-session/g" /etc/dcv/dcv.conf

sudo dnf install -y cups
sudo usermod -a -G sys dcv
sudo systemctl enable --now cups

sudo dnf install -y xorg-x11-drv-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/ec2-user/Desktop
. $DLAMI > /home/ec2-user/Desktop/README.md

if [ -f /usr/bin/nvidia-xconfig ]; then
  sudo /usr/bin/nvidia-xconfig --preserve-busid --enable-all-gpus
  sudo dnf install -y vulkan-tools glx-utils
  sudo systemctl enable --now dlami-cloudwatch-agent@partial
fi


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 ec2-user with your configured password

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

DLAMI notes

DLAMI notes can be located at /home/ec2-user/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.

AL2023 Deep Learning Desktop

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 Amazon Linux 2023 (AL2023) 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