Skip to content

Instantly share code, notes, and snippets.

@nathzi1505
Last active June 2, 2024 06:41
Show Gist options
  • Save nathzi1505/d2aab27ff93a3a9d82dada1336c45041 to your computer and use it in GitHub Desktop.
Save nathzi1505/d2aab27ff93a3a9d82dada1336c45041 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
@vsiegel
Copy link

vsiegel commented Dec 30, 2020

That script seems to be dangerous in its current form. That is certainly not intended.
From the file name install-docker.sh and the first couple of lines it is unambiguously a shell script to install something.
But part of the script is

## Erase all Docker images
docker rmi -f $(docker images -a -q)

This looks prone to unintended irreversible side effects possibly including data loss.
It seems to me it was meant as a command example, not as code to be executed.
I think the second line should start with an additional #.

@nathzi1505
Copy link
Author

nathzi1505 commented Dec 30, 2020

That script seems to be dangerous in its current form. That is certainly not intended.
From the file name install-docker.sh and the first couple of lines it is unambiguously a shell script to install something.
But part of the script is

## Erase all Docker images
docker rmi -f $(docker images -a -q)

This looks prone to unintended irreversible side effects possibly including data loss.
It seems to me it was meant as a command example, not as code to be executed.
I think the second line should start with an additional #.

Thank you so much @vsiegel for pointing it out. Most of my gists were created to serve mostly as code examples. Nevertheless, I still added a disclaimer, informing everyone.

Cheers and Happy New Year ✌🏻 !

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