Skip to content

Instantly share code, notes, and snippets.

@Merwanski
Created December 2, 2022 15:14
Show Gist options
  • Save Merwanski/b7de426e045f8ae22813c297b980e76f to your computer and use it in GitHub Desktop.
Save Merwanski/b7de426e045f8ae22813c297b980e76f to your computer and use it in GitHub Desktop.
install_docker_nvidia_linuxMint
# !/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=ubuntu18.04 \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.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
# 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-base nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment