- CPU architecture: x86
- Operating system: ubuntu18.04
Enough of the cumbersome deployment of the TensorRT+cuda+opencv+ffmpeg+x264 operating environment, every time the environment is deployed on a new server, it will take a lot of energy to deploy the environment. I heard that nvidia-docker can save the trouble of deployment. Many people It is also recommended to use docker for easy deployment. We also searched the Internet and studied it. According to the information on the Internet, we started to install docker to learn and record the learning records here. I heard that if you want to use GPU, you must install Docker-CE And NVIDIA Container Toolkit, ok, here we go.
1. Install Docker-CE
First of all, docker has not been installed on my machine, so I need to install docker first, execute the following script, and start the installation.
curl https://get.docker.com | sh \
> && sudo systemctl --now enable docker
The console output is as follows:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19325 100 19325 0 0 2210 0 0:00:08 0:00:08 --:--:-- 4718
# Executing docker install script, commit: 3255aa3919e7281693f62855b9d543bb50f04957
+ sudo -E sh -c apt-get update -qq >/dev/null
[sudo] dingxin 的密码:
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sudo -E sh -c mkdir -p /etc/apt/keyrings && chmod -R 0755 /etc/apt/keyrings
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
gpg: WARNING: unsafe ownership on homedir '/home/dingxin/.gnupg'
+ sudo -E sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sudo -E sh -c echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-scan-plugin >/dev/null
+ version_gte 20.10
+ [ -z ]
+ return 0
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null
+ sudo -E sh -c docker version
Client: Docker Engine - Community
Version: 20.10.16
API version: 1.41
Go version: go1.17.10
Git commit: aa7e414
Built: Thu May 12 09:17:28 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.16
API version: 1.41 (minimum version 1.12)
Go version: go1.17.10
Git commit: f756502
Built: Thu May 12 09:15:33 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.4
GitCommit: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16
runc:
Version: 1.1.1
GitCommit: v1.1.1-0-g52de29d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
================================================================================
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
dockerd-rootless-setuptool.sh install
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
to root access on the host. Refer to the 'Docker daemon attack surface'
documentation for details: https://docs.docker.com/go/attack-surface/
================================================================================
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
After the installation is complete, check the Docker version:
docker --version
The result is as follows:
Docker version 20.10.16, build aa7e414
Indicates that the installation was successful
Install NVIDIA Container Toolkit
Execute the following script:
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
The console output is as follows:
[sudo] dingxin 的密码:
OK
deb https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/$(ARCH) /
#deb https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/$(ARCH) /
deb https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/$(ARCH) /
#deb https://nvidia.github.io/nvidia-container-runtime/experimental/ubuntu18.04/$(ARCH) /
deb https://nvidia.github.io/nvidia-docker/ubuntu18.04/$(ARCH) /
Install the nvidia-docker2 package and its dependencies
sudo apt-get update
Console output:
命中:1 https://dl.google.com/linux/chrome/deb stable InRelease
命中:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
命中:3 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
命中:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
获取:5 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 InRelease [1,484 B]
命中:6 https://linux.teamviewer.com/deb stable InRelease
获取:7 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 InRelease [1,481 B]
命中:8 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
获取:9 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 InRelease [1,474 B]
获取:10 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 Packages [18.7 kB]
获取:11 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 Packages [7,416 B]
获取:12 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 Packages [4,488 B]
命中:13 https://download.docker.com/linux/ubuntu bionic InRelease
已下载 35.1 kB,耗时 3秒 (12.0 kB/s)
正在读取软件包列表... 完成
Then execute to install nvidia-docker2:
sudo apt-get install -y nvidia-docker2
The console output is as follows:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
linux-hwe-5.4-headers-5.4.0-100 linux-hwe-5.4-headers-5.4.0-104 linux-hwe-5.4-headers-5.4.0-105 linux-hwe-5.4-headers-5.4.0-107 linux-hwe-5.4-headers-5.4.0-109 linux-hwe-5.4-headers-5.4.0-42
linux-hwe-5.4-headers-5.4.0-89 linux-hwe-5.4-headers-5.4.0-90 linux-hwe-5.4-headers-5.4.0-91 linux-hwe-5.4-headers-5.4.0-92 linux-hwe-5.4-headers-5.4.0-94 linux-hwe-5.4-headers-5.4.0-96
linux-hwe-5.4-headers-5.4.0-99
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
libnvidia-container-tools libnvidia-container1 nvidia-container-toolkit
下列【新】软件包将被安装:
libnvidia-container-tools libnvidia-container1 nvidia-container-toolkit nvidia-docker2
升级了 0 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 38 个软件包未被升级。
需要下载 1,934 kB 的归档。
解压缩后会消耗 7,730 kB 的额外空间。
获取:1 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 libnvidia-container1 1.9.0-1 [926 kB]
获取:2 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 libnvidia-container-tools 1.9.0-1 [23.9 kB]
获取:3 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 nvidia-container-toolkit 1.9.0-1 [978 kB]
获取:4 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 nvidia-docker2 2.10.0-1 [5,532 B]
已下载 1,934 kB,耗时 58秒 (33.3 kB/s)
正在选中未选择的软件包 libnvidia-container1:amd64。
(正在读取数据库 ... 系统当前共安装有 462588 个文件和目录。)
正准备解包 .../libnvidia-container1_1.9.0-1_amd64.deb ...
正在解包 libnvidia-container1:amd64 (1.9.0-1) ...
正在选中未选择的软件包 libnvidia-container-tools。
正准备解包 .../libnvidia-container-tools_1.9.0-1_amd64.deb ...
正在解包 libnvidia-container-tools (1.9.0-1) ...
正在选中未选择的软件包 nvidia-container-toolkit。
正准备解包 .../nvidia-container-toolkit_1.9.0-1_amd64.deb ...
正在解包 nvidia-container-toolkit (1.9.0-1) ...
正在选中未选择的软件包 nvidia-docker2。
正准备解包 .../nvidia-docker2_2.10.0-1_all.deb ...
正在解包 nvidia-docker2 (2.10.0-1) ...
正在设置 libnvidia-container1:amd64 (1.9.0-1) ...
正在设置 libnvidia-container-tools (1.9.0-1) ...
正在设置 nvidia-container-toolkit (1.9.0-1) ...
正在设置 nvidia-docker2 (2.10.0-1) ...
正在处理用于 libc-bin (2.27-3ubuntu1.5) 的触发器 ...
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8 is not a symbolic link
/sbin/ldconfig.real: /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8 is not a symbolic link
The installation is complete
Then install the mirror
sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
Console output:
View downloaded images
sudo docker images -a
The console output is as follows:
View the currently running container:
sudo docker ps
The console output is as follows:
It seems that there are no running containers. After all, I just installed docker.
Pull a mirror down, such as ubuntu
sudo docker pull ubuntu