Created
July 31, 2015 06:55
-
-
Save danmactough/18b83dfbbdcec2d69b1c to your computer and use it in GitHub Desktop.
Setting up a gpu (nvidia) ec2 instance with ubuntu and electron for headless webgl rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/ | |
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 | |
EOF | |
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 http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run | |
chmod +x cuda_6.5.14_linux_64.run | |
mkdir nvidia_installers | |
./cuda_6.5.14_linux_64.run -extract=$(pwd)/nvidia_installers | |
pushd nvidia_installers | |
./NVIDIA-Linux-x86_64-340.29.run --ui=none --no-questions --accept-license --no-backup --no-nouveau-check --kernel-name=${NEW_KERNEL_NAME} | |
popd | |
rm cuda_6.5.14_linux_64.run | |
popd | |
export AWS_DEFAULT_REGION=$(curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document | command grep region | command awk -F\" '{print $4}') | |
INSTANCE_ID=$(curl --silent http://169.254.169.254/latest/meta-data/instance-id) | |
PUBLIC_HOSTNAME=$(curl --silent http://169.254.169.254/latest/meta-data/public-hostname) | |
# 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 | |
reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
appears the --enable-all-gpus option breaks nowsudo nvidia-xconfig --use-display-device=None --virtual=1280x1024 --output-xconfig=/etc/X11/xorg.conf --busid=PCI:0:3:0 --enable-all-gpus
tosudo 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 👿