Install and configure Ubuntu nodes with Nvidia drivers and NiceDCV (#3728)

These scripts will configure build and test Ubuntu 18/20 nodes with:

Nvidia gaming drivers for GPU instances (g4dn)
lightdm for Ubuntu 18 and gdm3 for Ubuntu 20 (wayland is disabled here, but should have xcb capabilities)
NiceDCV for remote console access

Note: Does not include user setup and firewall configurations

Signed-off-by: Mike Chang <changml@amazon.com>
monroegm-disable-blank-issue-2
Mike Chang 4 years ago committed by GitHub
parent a6e152370e
commit 6e3b03dfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,94 @@
#!/bin/bash
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# This script must be run as root
if [[ $EUID -ne 0 ]]
then
echo "This script must be run as root (sudo)"
exit 1
fi
# Install latest updates to AWS drivers and GCC (to build display driver)
#
echo Updating OS and tools
apt-get update -y
apt-get upgrade -y linux-aws
apt-get install -y gcc make linux-headers-$(uname -r)
# Install Desktop environment with tools. Nice is only compatible with Gnome
#
echo Installing desktop environment and tools
apt-get install ubuntu-desktop mesa-utils vulkan-tools awscli unzip -y
# Setup X desktop manager (Wayland needs to be turned off for GDM3)
#
if [ "`cat /etc/issue | grep 18.04`" != "" ] ; then
apt-get install lightdm -y
else
apt-get install gdm3 -y
sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf
systemctl restart gdm3
fi
# Set desktop environment to start by default
#
systemctl get-default
systemctl set-default graphical.target
systemctl isolate graphical.target
# Prepare for the nVidia driver by disabling nouveau
#
cat << EOF | sudo tee --append /etc/modprobe.d/blacklist.conf
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
EOF
# Blocking nouveau from activating during grub startup
#
echo 'GRUB_CMDLINE_LINUX="rdblacklist=nouveau"' >> /etc/default/grub
update-grub
# Copy drivers to local, then install
#
aws s3 cp --recursive s3://nvidia-gaming/linux/latest/ /tmp
cd /tmp
unzip NVIDIA-Linux-x86_64* \
&& rm NVIDIA-Linux-x86_64* \
&& chmod +x Linux/NVIDIA-Linux-x86_64*.run \
&& Linux/NVIDIA-Linux-x86_64*.run --accept-license \
--no-questions \
--no-backup \
--ui=none \
--install-libglvnd \
&& nvidia-xconfig --preserve-busid --enable-all-gpus \
&& rm -rf /tmp/Linux
# Download and configure licenses (needed for VMs and multiuser)
#
cat << EOF | sudo tee -a /etc/nvidia/gridd.conf
vGamingMarketplace=2
EOF
curl -o /etc/nvidia/GridSwCert.txt "https://nvidia-gaming.s3.amazonaws.com/GridSwCert-Archive/GridSwCertLinux_2021_10_2.cert"
# Optimize settings if headless
#
if [ ! $DISPLAY ] ; then
echo Headless instance found. Disabling HardDPMS
if [ ! $(grep '"HardDPMS" "false"' /etc/X11/xorg.conf) ]; then
sed -i '/BusID */ a\
Option "HardDPMS" "false"' /etc/X11/xorg.conf
fi
fi
echo Install complete!
read -t 10 -p "Rebooting in 10 seconds. Press enter to reboot this instance now or CTRL+c to cancel"
reboot now

@ -0,0 +1,78 @@
#!/bin/bash
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# This script must be run as root
if [[ $EUID -ne 0 ]]
then
echo "This script must be run as root (sudo)"
exit 1
fi
# Download Nice DCV
#
echo Downloading Nice-DCV
mkdir /tmp/nice-dcv
cd /tmp/nice-dcv
curl -sSL https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY | gpg --import -
if [ "`cat /etc/issue | grep 18.04`" != "" ] ; then
dcv_server=`curl --silent --output - https://download.nice-dcv.com/ | \
grep href | egrep "$dcv_version" | egrep "ubuntu1804" | grep Server | \
sed -e 's/.*http/http/' -e 's/tgz.*/tgz/' | head -1`
else
dcv_server=`curl --silent --output - https://download.nice-dcv.com/ | \
grep href | egrep "$dcv_version" | egrep "ubuntu2004" | grep Server | \
sed -e 's/.*http/http/' -e 's/tgz.*/tgz/' | head -1`
fi
# Install Nice DCV
#
echo Installing DCV from $dcv_server
wget $dcv_server \
&& tar zxvf nice-dcv-*ubun*.tgz
cd nice-dcv-*64
apt install -y ./nice-*amd64.ubuntu*.deb \
&& usermod -aG video dcv \
&& rm -rf /tmp/nice-dcv
# Setup multiuser environment for DCV
#
systemctl isolate multi-user.target
sleep 1
dcvgladmin enable
systemctl isolate graphical.target
# Check if DCV localuser for X has been setup correctly
#
if [ $(DISPLAY=:0 XAUTHORITY=$(ps aux | grep "X.*\-auth" | grep -v grep | sed -n 's/.*-auth \([^ ]\+\).*/\1/p') xhost | grep "SI:localuser:dcv$") ]; then
echo DCV localuser validated
else
echo [ERROR] DCV localuser not found. Output should be: SI:localuser:dcv. Exiting with 1
exit 1
fi
# Configure DCV for auto start sessions and performance
#
sed -i "s/#create-session = true/create-session = true/g" /etc/dcv/dcv.conf
sed -i "s/#owner=\"session-owner\"/owner=\"$LOGNAME\"/g" /etc/dcv/dcv.conf
sed -i "s/#target-fps=30/target-fps=0/g" /etc/dcv/dcv.conf
# Enable and start the DCV server
#
systemctl enable dcvserver
systemctl start dcvserver
# Output the DCV installation diagnostics
#
dcvgldiag
# Start a DCV session to login
#
IP_ADDR=$(curl http://checkip.amazonaws.com)
echo Starting DCV desktop session for $LOGNAME. Session can be accessed at https://$IP_ADDR:8443
dcv create-session --type=console --owner $LOGNAME desktop
Loading…
Cancel
Save