Skip to content

Instantly share code, notes, and snippets.

@nathantsoi
Last active August 31, 2025 12:39
Show Gist options
  • Select an option

  • Save nathantsoi/e668e83f8cadfa0b87b67d18cc965bd3 to your computer and use it in GitHub Desktop.

Select an option

Save nathantsoi/e668e83f8cadfa0b87b67d18cc965bd3 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
sudo apt-get install -y docker-ce
# install nvidia-container-toolkit
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --yes --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && \
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
# Test nvidia-smi with the latest official CUDA image
echo "DONE!"
echo "Add your user to the docker group:"
echo ' sudo usermod -aG docker $USER'
echo " Login again and test with:"
echo " docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi"
@nathantsoi
Copy link
Author

nathantsoi commented Sep 24, 2020

curl -L https://gist.githubusercontent.com/nathantsoi/e668e83f8cadfa0b87b67d18cc965bd3/raw/setup_docker.sh | sudo bash

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