Ubuntu 18.04 installation Docker CE and step NVIDIA Container Toolkit

Docker's one of the benefits is that you can freely messing around in Container inside, do not get worried collapse Host environment.

In order to support the GPU docker in, before NVidia is broke nvidia-docker2, now upgraded to the NVIDIA Container Toolkit. Official statement is "Usage of nvidia-docker2 packages are deprecated since NVIDIA GPUs are now natively supported as devices in the Docker runtime".

Ubuntu 18.04 installation Docker CE and step NVIDIA Container Toolkit

Installation Environment

  • OS: 18.04 64 bit
  • Graphics: NVidia GTX 2080 Ti x 2
  • CUDA: 10.0
  • cnDNN: 7.4

Task: Install Docker CE and NVIDIA Container Toolkit, in order to carry out post-depth study

Docker source configuration
# update the source
$ sudo apt update

# 启用HTTPS
$ sudo apt install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

# 添加GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Stable version of the source added
$ sudo the Add-APT-Repository \
  "deb [Arch = AMD64] https://download.docker.com/linux/ubuntu \
  $ (lsb_release -cs) \
  stable"

Installation Docker CE

At the moment Docker version requires 19.03 thereafter may need to be updated.
# Update the source
$ sudo apt update

# 安装Docker CE
$ sudo apt install -y docker-ce

If the installation fails in this way, there are solutions.
 When an error is displayed on the screen to download the deb file failed, try to download it, and then one by one manually install just fine.

At the moment I need to download is the following three files, then you can update to the latest version at the time:

  • containerd.io_1.2.6-3_amd64.deb
  • docker-ce-cli_19.03.0~3-0~ubuntu-bionic_amd64.deb
  • docker-ce_19.03.0~3-0~ubuntu-bionic_amd64.deb

手动依次安装:
$ sudo dpkg -i containerd.io_1.2.6-3_amd64.deb
$ sudo dpkg -i docker-ce-cli_19.03.0~3-0~ubuntu-bionic_amd64.deb
$ sudo dpkg -i docker-ce_19.03.0~3-0~ubuntu-bionic_amd64.deb

Verify Docker CE

If the following content appears, the installation was successful.
$ Sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Nvidia-docker source configuration
# Add Source
$ Distribution = $ (/ etc / OS-Release; echo $ $ VERSION_ID ID.)
$ Curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | the sudo the Add-Key APT -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo TEE /etc/apt/sources.list.d/nvidia-docker .list

# 安装并重启docker
$ sudo apt update && sudo apt install -y nvidia-container-toolkit
$ sudo systemctl restart docker

Use
# CUDA mirrored in the official test-SMI NVIDIA
$ sudo Docker RUN --gpus All NVIDIA / CUDA: Base 9.0-NVIDIA-SMI

# Start supports dual GPU container
$ sudo docker run --gpus 2 nvidia / cuda: 9.0-base nvidia-smi

# Specify GPU 1, operation of the container
$ sudo docker run --gpus device = 0 nvidia / cuda: 9.0-base nvidia-smi

Can see the video card information to explain the OK, the current image is based on Ubuntu 16.04's.

Guess you like

Origin www.linuxidc.com/Linux/2019-07/159613.htm