Skip to content

Instantly share code, notes, and snippets.

@gangiman
Created January 15, 2019 09:51
Show Gist options
  • Save gangiman/725b5852906034fee7cc9d52a7740e67 to your computer and use it in GitHub Desktop.
Save gangiman/725b5852906034fee7cc9d52a7740e67 to your computer and use it in GitHub Desktop.
#!/bin/bash
NVIDIA_DRIVER=/tmp/NVIDIA-Linux-x86_64-410.78.run
DRIVER_URL=http://us.download.nvidia.com/XFree86/Linux-x86_64/410.78/NVIDIA-Linux-x86_64-410.78.run
BLACKLIST_FILE=/etc/modprobe.d/blacklist-nvidia-nouveau.conf
if [ ! -f $BLACKLIST_FILE ]; then
echo "Disabling nouveau driver and then rebooting..."
bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
# Enter the following linux command to regenerate initramfs
update-initramfs -u
reboot
else
dpkg --add-architecture i386
apt update
apt -y install build-essential libc6:i386
wget --user-agent='Chrome' $DRIVER_URL -O $NVIDIA_DRIVER
bash $NVIDIA_DRIVER
# Full instruction at
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
# Next, install a few prerequisite packages which let apt use packages over HTTPS
echo "Installing Docker..."
apt install -y apt-transport-https ca-certificates curl software-properties-common
# Then add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Add the Docker repository to APT sources
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
# Next, update the package database with the Docker packages from the newly added repo:
apt update
# Install docker-ce
apt install -y docker-ce
echo "Installing nvidia-docker2..."
# https://medium.com/@sh.tsang/docker-tutorial-5-nvidia-docker-2-0-installation-in-ubuntu-18-04-cb80f17cac65
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
apt-get update
apt-get install -y nvidia-docker2
pkill -SIGHUP dockerd
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment