Created
December 2, 2022 15:17
-
-
Save Merwanski/77b8276b24c90ec7c817840c3129a42a to your computer and use it in GitHub Desktop.
install_docker_nvidia ubuntu 20.04
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 | |
# Installation instructions from https://docs.docker.com/engine/install/ubuntu/ | |
# Update the apt package index and install packages to allow apt to use a repository over HTTPS: | |
sudo apt update | |
sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |
# Add Docker’s official GPG key | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
# Use the following command to set up the stable repository | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
# INSTALL DOCKER ENGINE | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | |
# Install Docker with NVIDIA support | |
# Docker-CE on Ubuntu can be installed using Docker's official convenience script: | |
curl https://get.docker.com | sh && sudo systemctl --now enable docker | |
# Setting up NVIDIA Container Toolkit | |
# Setup the stable repository and the GPG key: | |
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ | |
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \ | |
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list | |
# Install the nvidia-docker2 package (and dependencies) after updating the package listing: | |
sudo apt-get update | |
sudo apt-get install -y nvidia-docker2 | |
# Restart the Docker daemon to complete the installation after setting the default runtime: | |
sudo systemctl restart docker | |
# At this point, a working setup can be tested by running a base CUDA container: | |
sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment