Skip to content

Instantly share code, notes, and snippets.

@arpat
Last active June 6, 2018 16:42
Show Gist options
  • Save arpat/bff892192d0fcbc4f4fc to your computer and use it in GitHub Desktop.
Save arpat/bff892192d0fcbc4f4fc to your computer and use it in GitHub Desktop.
AWS blender Workstation allowing thinclient use over TurboVNC
#!/bin/bash
# Auth: Arun Patel 2015, Creative Commons License
# Ubuntu 14.04:
# This script blacklists the nouveau nvidia driver,
# and updated the initramfs and prepares for the
# NVIDIA proprietry driver build.
echo " ********************************************"
echo " ACCEPT the (default) boot/grub/menu.lst "
echo " keep the local version currently installed. "
echo " when the installer prompts for it. "
echo " ********************************************"
sleep 3
apt-get -y update
apt-get -y remove apparmor libapparmor-perl libapparmor1
cat << EoS - > /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# generated by arunsmtp -before NVIDIA installer
blacklist nouveau
options nouveau modeset=0
EoS
apt-get -y install build-essential linux-image-extra-virtual cmake
depmod --all --errsyms && update-initramfs -u
echo Reeebooooot now manually please...
#!/bin/bash
# WORK IN PROGRESS -DON'T RUN THIS, THERE'S SOME MINOR BUGS
# Auth: Arun Patel 2015, Creative Commons License
# Ubuntu 14.04:
# This script runs the NVIDIA proprietry installer,
# adding required packages and xorg.conf.
# Also the VirtualGL/TurboVNC packages are added
# and configured, for the glroup vglusers.
GfxUser="ubuntu"
# Download the NVIDIA proprietry driver, install is a few lines below.
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/352.63/NVIDIA-Linux-x86_64-352.63.run
apt-get -y install linux-headers-$(uname -r)
apt-get -y install xorg openbox libgl1-mesa-dev libglu1-mesa-dev libpam0g-dev xdm mesa-utils unzip
service xdm stop
# Execute the NVIDIA run script in unattended mode.
# similar to --no-questions --accept-license --silent --run-nvidia-xconfig
chmod +x ./NVIDIA-Linux-x86_64-*.run
./NVIDIA-Linux-x86_64-352.63.run -q -a -n -X -s
echo NVIDIA diver install ended.
# get the PCI bus ID for insertion into the xorg.conf below
echo Getting the correct PCI Bus ID for the right GPU may not work automatically.
echo Look at the file /root/xorg.conf.new which should show all the detected GPUs
X -configure && BusID=$(cat /root/xorg.conf.new | egrep -A1 -i "nouveau|nvidia" | grep BusID)
# Install an xorg.conf that enables the nvidia GPU in headless mode.
# PCI bus id hopefully stops other video cards getting enabled.
cat << Eos - > /etc/X11/xorg.conf
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 340.96 (buildmeister@swio-display-x86-rhel47-05) Sun Nov 8 22:50:27 PST 2015
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
EndSection
Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psaux"
Option "Emulate3Buttons" "no"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 28.0 - 33.0
VertRefresh 43.0 - 72.0
Option "DPMS"
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
$BusID
EndSection
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "AllowEmptyInitialConfiguration" "True"
SubSection "Display"
Depth 24
EndSubSection
EndSection
Eos
# Xorg config done.
# Download and install the VirtualGL, TurboVNC and libjpeg packages
wget http://downloads.sourceforge.net/project/virtualgl/2.4.1/virtualgl_2.4.1_amd64.deb
wget http://downloads.sourceforge.net/project/turbovnc/2.0.1/turbovnc_2.0.1_amd64.deb
wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.4.2/libjpeg-turbo-official_1.4.2_amd64.deb
dpkg -i libjpeg-turbo-official_1.4.2_amd64.deb
dpkg -i virtualgl_2.4.1_amd64.deb
dpkg -i turbovnc_2.0.1_amd64.deb
# Set VirtualLG defaults, xauth bits, this adds a DRI line to xorg.conf.
/opt/VirtualGL/bin/vglserver_config -config -s -f +t
# Allow a user to access the VirtualGL stuff
usermod -a -G vglusers $GfxUser
# Restart X, hopefully /var/log/Xorg.0.log shows a working X process
service xdm restart
# Install the CUDA components so blender can utilize the GPU for Cycles
# multiverse has to be enabled for this, so we do this as a separate entry
grep -i multiverse /etc/apt/sources.list | sed 's/^#\ deb/deb/' > /etc/apt/sources.list.d/AWS-GPU-prep-script.1.list
apt-get update
apt-get -y install nvidia-modprobe nvidia-cuda-toolkit
# Finally install blender
apt-get -y install blender
#!/bin/bash
# Auth: Arun Patel 2015, Creative Commons License
# Ubuntu 14.04:
# The VirtualGL end user should run this to prep the
# environment to allow VirtualGL to server the VNC
# output rendered on the GPU to the TurboVNC viewer.
#
## As ubuntu user allow youself connection to the X server.
xauth merge /etc/opt/VirtualGL/vgl_xauth_key
## Check its all enabled -look for ‘P’ in last column.
/opt/VirtualGL/bin/glxinfo -display :0 -c | tail
# Start a TurboVNC server session for you, make note of the
# display number (probably :1) -see VNC documentation.
/opt/TurboVNC/bin/vncserver
# Run your OpenGL software with the virtualgl wrapper like
# /opt/VirtualGL/bin/vglrun glxgears once you established
# a TurboVNC session.
@arpat
Copy link
Author

arpat commented Dec 28, 2015

These scripts set up an EC2 GPU instance to run blender with CUDA over a TurboVNC/VirtualGL connection allowing thinclient use.
Works well, currently for Ubuntu 14.04.2 LTS on EC2. Setup takes about 6 mins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment