Last active
March 7, 2023 05:55
-
-
Save jgwerner/e270e198e7b8cc68b1978de6701ad149 to your computer and use it in GitHub Desktop.
Nvidia docker installation script
This file contains 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
# based in large part from https://raw.githubusercontent.com/khwilson/nvidia-docker-aws/master/nvidia.sh | |
#!/bin/bash | |
set -x | |
set -e | |
# Update and upgrade | |
echo "--" | |
echo "-- Running ubuntu updates and Ugrade" | |
sudo su - -c "apt-get update; apt-get -y upgrade;" | |
echo "--" | |
echo "-- Install Docker apt keys and update" | |
# Install docker with apt-get package manager. Alternative: | |
# curl -sSL https://get.docker.com | sh | |
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
sudo echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list | |
sudo su - -c "apt-get update" | |
sudo su - -c "apt-cache policy docker-engine" | |
echo "-- Docker Install Complete" | |
# Install requirements first | |
sudo su - -c "apt-get install -y linux-image-extra-virtual" | |
echo "--" | |
echo "-- Install Docker" | |
# Install docker | |
sudo su - -c "apt-get install -y docker-engine" | |
sleep 5 | |
echo "-- Test Docker" | |
# Test docker install | |
sudo su - -c "docker run hello-world" | |
sleep 10 | |
echo "--" | |
echo "Update ubuntu user permission to run docker" | |
# Add docker user to sudoers | |
sudo usermod -aG docker ubuntu | |
echo "--" | |
echo "-- Install Nvidia-docker" | |
# Install *latest* nvidia drivers | |
sudo su - -c "add-apt-repository -y ppa:graphics-drivers/ppa" | |
sudo su - -c "apt-get update" | |
sudo su - -c "apt-get install -y nvidia-375" | |
echo "--" | |
echo "-- Install kernel module" | |
# Install the kernel module | |
sudo su - -c "apt-get install -y nvidia-modprobe" | |
echo "--" | |
echo "-- Add nvidia-docker extentions" | |
# Add nvidia-docker extension. | |
# Update to latest release https://github.com/NVIDIA/nvidia-docker/releases | |
sudo wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb | |
sudo su - -c "dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb" | |
echo "--" | |
echo "-- Testing Nvidia" | |
# Verify | |
sudo su - -c "nvidia-docker run --rm nvidia/cuda:7.0 nvidia-smi" | |
sleep 5 | |
# *** this didn't seem to work got a Unknown error 524 when moving files. | |
# Move the docker images to /mnt | |
#sudo su - -c "service docker stop" | |
#sleep 5 | |
#sudo su - -c "mv -f /var/lib/docker /mnt" | |
#sudo su - -c "ln -s /mnt/docker /var/lib/docker" | |
#sudo su - -c "service docker start" | |
sudo su - -c "nvidia-docker run --rm nvidia/cuda:7.0 nvidia-smi" | |
echo "--" | |
echo "-- Black list nouveau drivers" | |
# Blacklist nouveau: | |
sudo su - -c 'echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf' | |
sudo su - -c 'echo "blacklist lbm-nouveau" >> /etc/modprobe.d/blacklist.conf' | |
sudo su - -c 'echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist.conf' | |
sudo su - -c 'echo "alias nouveau off" >> /etc/modprobe.d/blacklist.conf' | |
sudo su - -c 'echo "alias lbm-nouveau off" >> /etc/modprobe.d/blacklist.conf' | |
sudo su - -c "update-initramfs -u" | |
echo "-- Install Nvidia-docker-compose" | |
sudo apt-get install -y python-pip | |
# pip install nvidia-docker-compose | |
echo "--" | |
echo "-- Finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment