Install Docker and NVIDIA Container Toolkit on Ubuntu

Reference: Nvidia's Installation Guide

Setup Docker

curl https://get.docker.com | sh \
  && sudo systemctl --now enable docker

After installation, the script will show a message to setup rootless docker service, a shell named dockerd-rootless-setuptool.sh are installed in /usr/bin/

dockerd-rootless-setuptool.sh install

And the following message are shown:

[INFO] Installed docker.service successfully.
[INFO] To control docker.service, run: `systemctl --user (start|stop|restart) docker.service`
[INFO] To run docker.service on system startup, run: `sudo loginctl enable-linger shennong`

[INFO] Creating CLI context "rootless"
Successfully created context "rootless"

[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):

export PATH=/usr/bin:$PATH
export DOCKER_HOST=unix:///run/user/1000/docker.sock

Setup NVIDIA Container Toolkit

Setup Nvidia Container Toolkit as the Install Guide described

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 update
sudo apt install -y nvidia-docker2

restart the docker engine and run a test container to check nvidia-docker

sudo systemctl restart docker
sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

你可能感兴趣的:(Install Docker and NVIDIA Container Toolkit on Ubuntu)