docker, and nvidia_docker installation

Install docker

Set up index library

  1. Update apt package index
$ sudo apt-get update  

Insert picture description here
2. Install the package to allow the use of the repository via HTTPS:

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Insert picture description here
3. Add Docker's official GPG key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$  sudo apt-key fingerprint 0EBFCD88

Insert picture description here
Insert picture description here
4. Use the following command to set up the stable repository. Even if you still want to install and build from an edge or test repository, you always need a stable repository. To add an edge or test repository, add the word edge or test (or both) after the word stable in the following command

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

Note: $(lsb_release -cs) can be replaced, Ubuntu18.04 corresponds to bionic, and Ubuntu16.04 corresponds to xenial

There is a pit at this time. When an error is added, an error will be reported in the update. Need to add and delete the wrong, and then update.
Insert picture description here

Install docker ce

  1. Update apt index library
sudo apt-get update

a. Install the latest version of docker CE

$ sudo apt-get install docker-ce

b. Or install the specified version:

  • List the available versions in the warehouse
$ apt-cache madison docker-ce
docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
  • Install a specific version by its fully qualified package name, which is the package name (docker-ce) "=" version string (column 2), for example, docker-ce = 18.03.0ce-0ubuntu.
$ sudo apt-get install docker-ce=<VERSION>
  1. View docker ce version
$ docker -v 

Check if it is installed correctly

Verify that Docker CE is installed correctly by running the hello-world image.

sudo docker run hello-world

nvidia docker

The Docker version must be greater than 19.03. Install nvidia-container-toolkit on this basis to enable Docker GPU acceleration.

Basic environment: Ubuntu 16.04/18.04, Debian Jessie/Stretch/Buster

# Add the package repositories
$ 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

Usage example:

#### Test nvidia-smi with the latest official CUDA image
$ docker run --gpus all nvidia/cuda:9.0-base nvidia-smi

# Start a GPU enabled container on two GPUs
$ docker run --gpus 2 nvidia/cuda:9.0-base nvidia-smi

# Starting a GPU enabled container on specific GPUs
$ docker run --gpus '"device=1,2"' nvidia/cuda:9.0-base nvidia-smi
$ docker run --gpus '"device=UUID-ABCDEF,1"' nvidia/cuda:9.0-base nvidia-smi

# Specifying a capability (graphics, compute, ...) for my container
# Note this is rarely if ever used this way
$ docker run --gpus all,capabilities=utility nvidia/cuda:9.0-base nvidia-smi

Guess you like

Origin blog.csdn.net/wwwangzai/article/details/108780396