Last active
August 31, 2025 12:39
-
-
Save nathantsoi/e668e83f8cadfa0b87b67d18cc965bd3 to your computer and use it in GitHub Desktop.
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 | |
| 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.