Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Setting up a gpu (nvidia) ec2 instance with ubuntu and electron for headless webgl rendering
#!/bin/bash -xe
# Unload nouveau
sudo rmmod nouveau
# Load nvidia
sudo modprobe nvidia
# Configure X
sudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0 --enable-all-gpus
#!/bin/bash -xe
# Update
apt-get update -y
# Install necessary packages
export DEBIAN_FRONTEND=noninteractive
apt-get install -y git build-essential libssl-dev awscli python-setuptools libgtk2.0 libgconf-2-4 libnss3 libasound2 dbus-x11 xorg linux-image-extra-virtual linux-source linux-headers-generic
# Disable nouveau driver
# Ref:
cat << EOF | tee /etc/modprobe.d/blacklist-nouveau.conf
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
echo options nouveau modeset=0 | tee -a /etc/modprobe.d/nouveau-kms.conf
NEW_KERNEL_NAME=$(dpkg --list | command grep linux-image-3 | awk '{ print $2 }' | sort -r | head -n 1 | sed -e 's/linux-image-//')
# Download, compile, and install NVIDIA drivers
pushd /home/ubuntu
wget -nd -q
chmod +x
mkdir nvidia_installers
./ -extract=$(pwd)/nvidia_installers
pushd nvidia_installers
./ --ui=none --no-questions --accept-license --no-backup --no-nouveau-check --kernel-name=${NEW_KERNEL_NAME}
export AWS_DEFAULT_REGION=$(curl --silent | command grep region | command awk -F\" '{print $4}')
INSTANCE_ID=$(curl --silent
PUBLIC_HOSTNAME=$(curl --silent
# Notify that step 1 is complete
# aws sns publish \
# --topic-arn <your_arn> \
# --message "Headless Graphics EC2 instance ready for setup step 2. Instance id: ${INSTANCE_ID} Hostname: ${PUBLIC_HOSTNAME}" \
# --subject "EC2 instance ready"
# reboot

This comment has been minimized.

Copy link
Owner Author

@danmactough danmactough commented Oct 18, 2015

appears the --enable-all-gpus option breaks now
sudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0 --enable-all-gpus

sudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0

false -- that only happens if the nouveau driver is still loaded 👿

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.