Skip to content

Instantly share code, notes, and snippets.

@ychevarrias
Forked from p3jitnath/install-docker.sh
Created January 6, 2021 07:38
Show Gist options
  • Save ychevarrias/4a65bfe5fd47d26b5b1cfa9f90e94699 to your computer and use it in GitHub Desktop.
Save ychevarrias/4a65bfe5fd47d26b5b1cfa9f90e94699 to your computer and use it in GitHub Desktop.
Docker and Nvidia Docker installation in Ubuntu 20.04 LTS
# WARNING : This gist in the current form is a collection of command examples. Please exercise caution where mentioned.
# Docker
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
docker --version
# Put the user in the docker group
sudo usermod -a -G docker $USER
newgrp docker
# Nvidia Docker
sudo apt install curl
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
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
# Check Docker image
docker run --gpus all nvidia/cuda:10.0-base nvidia-smi
## Erase all Docker images [!!! CAUTION !!!]
# docker rmi -f $(docker images -a -q)
## Erase one Docker image [!!! CAUTION !!!]
# docker ps
# docker rmi -f image_id
## Running GUI Applications
xhost +local:docker
docker run --gpus all -it \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
nathzi1505:darknet bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment