install-ubuntu-gpu.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. # Install latest updates to AWS drivers and GCC (to build display driver)
  14. #
  15. echo Updating OS and tools
  16. apt-get update -y
  17. apt-get upgrade -y linux-aws
  18. apt-get install -y gcc make linux-headers-$(uname -r)
  19. # Install Desktop environment with tools. Nice is only compatible with Gnome
  20. #
  21. echo Installing desktop environment and tools
  22. apt-get install ubuntu-desktop mesa-utils vulkan-tools awscli unzip -y
  23. # Setup X desktop manager (Wayland needs to be turned off for GDM3)
  24. #
  25. if [ "`cat /etc/issue | grep 18.04`" != "" ] ; then
  26. apt-get install lightdm -y
  27. else
  28. apt-get install gdm3 -y
  29. sed -i 's/#WaylandEnable=false/WaylandEnable=false/g' /etc/gdm3/custom.conf
  30. systemctl restart gdm3
  31. fi
  32. # Set desktop environment to start by default
  33. #
  34. systemctl get-default
  35. systemctl set-default graphical.target
  36. systemctl isolate graphical.target
  37. # Prepare for the nVidia driver by disabling nouveau
  38. #
  39. cat << EOF | sudo tee --append /etc/modprobe.d/blacklist.conf
  40. blacklist vga16fb
  41. blacklist nouveau
  42. blacklist rivafb
  43. blacklist nvidiafb
  44. blacklist rivatv
  45. EOF
  46. # Blocking nouveau from activating during grub startup
  47. #
  48. echo 'GRUB_CMDLINE_LINUX="rdblacklist=nouveau"' >> /etc/default/grub
  49. update-grub
  50. # Copy drivers to local, then install
  51. #
  52. aws s3 cp --recursive s3://nvidia-gaming/linux/latest/ /tmp
  53. cd /tmp
  54. unzip NVIDIA-Linux-x86_64* \
  55. && rm NVIDIA-Linux-x86_64* \
  56. && chmod +x Linux/NVIDIA-Linux-x86_64*.run \
  57. && Linux/NVIDIA-Linux-x86_64*.run --accept-license \
  58. --no-questions \
  59. --no-backup \
  60. --ui=none \
  61. --install-libglvnd \
  62. && nvidia-xconfig --preserve-busid --enable-all-gpus \
  63. && rm -rf /tmp/Linux
  64. # Download and configure licenses (needed for VMs and multiuser)
  65. #
  66. cat << EOF | sudo tee -a /etc/nvidia/gridd.conf
  67. vGamingMarketplace=2
  68. EOF
  69. curl -o /etc/nvidia/GridSwCert.txt "https://nvidia-gaming.s3.amazonaws.com/GridSwCert-Archive/GridSwCertLinux_2021_10_2.cert"
  70. # Optimize settings if headless
  71. #
  72. if [ ! $DISPLAY ] ; then
  73. echo Headless instance found. Disabling HardDPMS
  74. if [ ! $(grep '"HardDPMS" "false"' /etc/X11/xorg.conf) ]; then
  75. sed -i '/BusID */ a\
  76. Option "HardDPMS" "false"' /etc/X11/xorg.conf
  77. fi
  78. fi
  79. echo Install complete!
  80. read -t 10 -p "Rebooting in 10 seconds. Press enter to reboot this instance now or CTRL+c to cancel"
  81. reboot now