Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use NVIDIA graphics card in docker19.03

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how docker19.03 uses NVIDIA graphics cards. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Introduction to the use of NVIDIA graphics card for docker19.03

Docker 19.03 has been officially released in July 2019, and this release has two bright spots for me.

1, that is, docker does not need root permission to start the drinking operation.

2. It supports the enhanced function of GPU. If we want to read the nvidia graphics card in docker, we no longer need to install nvidia-docker.

Install the nvidia driver

Confirm that the NVIDIA card is detected:

$lspci-vv | grep-I nvidia00:04.0 3D controller: NVIDIA Corporation GP100GL [Tesla P100 PCIe 16GB] (rev A1) Subsystem: NVIDIA Corporation GP100GL [Tesla P100 PCIe 16GB] Kernel modules: nvidiafb

I won't go into details here: if you don't know, please move to ubuntu to install TTS service offline.

Install NVIDIA Container Runtime$ cat nvidia-container-runtime-script.shcurl-s-L https://nvidia.github.io/nvidia-container-runtime/gpgkey |\ sudo apt-key add-distribution=$ (. / etc/os-release Echo $ID$VERSION_ID) curl-s-L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list |\ sudo tee / etc/apt/sources.list.d/nvidia-container-runtime.listsudo apt-get update execute script sh nvidia-container-runtime-script.shOKdeb https://nvidia.github.io/libnvidia-container/ubuntu18.04/$(ARCH) / deb https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04 / $(ARCH) / Hit:1 http://archive.canonical.com/ubuntu bionic InReleaseGet:2 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64 InRelease [1139 B] Get:3 https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64 InRelease [1136 B] Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease Get:5 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64 Packages [4076 B] Get:6 https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64 Packages [3084 B] Hit:7 http://us-east4-c.gce.clouds.archive.ubuntu.com/ubuntu bionic InReleaseHit:8 http://us-east4-c.gce.clouds. Archive.ubuntu.com/ubuntu bionic-updates InReleaseHit:9 http://us-east4-c.gce.clouds.archive.ubuntu.com/ubuntu bionic-backports InReleaseFetched 9435 B in 1s (17.8 kB/s) Reading package lists... Done$ apt-get install nvidia-container-runtimeReading package lists... DoneBuilding dependency tree Reading state information... DoneThe following packages were automatically installed and are no longer required: grub-pc-bin libnuma1Use 'sudo apt autoremove' toremove them.The following additional packages will be installed:Get:1 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64 libnvidia-container1 1.0.2-1 [59.1 kB] Get:2 https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64 libnvidia-container-tools 1.0.2-1 [15.4 kB] Get:3 https:/ / nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64 nvidia-container-runtime-hook 1.4.0-1 [575 kB]... Unpacking nvidia-container-runtime (2.0.0+docker18.09.6-3)... Setting up libnvidia-container1:amd64 (1.0.2-1)... Setting up libnvidia-container-tools (1.0.2-1)... Processing triggers for libc-bin (2.27-3ubuntu1)... Setting Up nvidia-container-runtime-hook (1.4.0-1)... Setting up nvidia-container-runtime (2.0.0+docker18.09.6-3)... which nvidia-container-runtime-hook/usr/bin/nvidia-container-runtime-hook installation docker-19.03# step 1: install some necessary system tools yum install-y yum-utils device-mapper-persistent-data lvm2# Step 2: add software source information yum-config-manager -- add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# Step 3: update and install Docker-CEyum makecache fastyum-y install docker-ce-19.03.2# Step 4: open the Docker service systemctl start docker & & systemctl enable docker verify whether the docker version is installed properly $docker versionClient: Docker Engine-Community Version: 19.03.2 API version: 1.40 Go version: Go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:28:55 2019 OS/Arch: linux/amd64 Experimental: falseServer: Docker Engine-Community Engine: Version: 19.03.2 API version: 1.40 (minimum version 1.12) Go version: go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:27:34 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.6 GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc: Version: 1.0.0-rc8 GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f docker-init: Version: 0.18.0 GitCommit: fec3683 Verification-gpus option $docker run-- help | grep-I gpus-- gpus gpu-request GPU devices to add to the container ('all' to pass all GPUs) runs the Ubuntu container using GPU $docker run-it-- rm-- gpus all ubuntu nvidia-smiUnable to find image' ubuntu:latest' locallylatest: Pulling from library/ubuntuf476d66f5408: Pull complete 8882c27f669e: Pull complete d9af21273955: Pull complete f5029279ec12: Pull complete Digest: sha256:d26d529daa4d8567167181d9d569f2a85da3c5ecaf539cace2c6223355d69981Status: Downloaded newer image for ubuntu:latestTue May 7 15:52:15 2019 +- -+ | NVIDIA-SMI 390.116 Driver Version: 390.116 | -+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | = = + = | 0 Tesla P4 Off | 00000000Memory-Usage 04.0 Off | 0 | | A 39C P022W / 75W | 0MiB / 7611MiB | 0 Default | + -+-- + | Processes: GPU Memory | | GPU PID Type Process name Usage | | = = | | No running processes found | +- -+: ~ $troubleshooting

Did you encounter the following error message:

Docker run-it-- rm-- gpus all debiandocker: Error response from daemon: linux runtime spec devices: could not select device driver "" with capabilities: [[gpu]].

The above error means that Nvidia cannot register Docker correctly. It actually means that the driver is not installed correctly on the host. This may also mean that the nvidia container tools are installed without restarting the docker daemon: you need to restart the docker daemon.

I suggest you go back and verify that nvidia-container-runtime is installed or restart the Docker daemon.

List GPU devices $docker run-it-- rm-- gpus all ubuntu nvidia-smi-LGPU 0: Tesla P4 (UUID: GPU-fa974b1d-3c17-ed92-28d0-805c6d089601) $docker run-it-- rm-- gpus all ubuntu nvidia-smi-- query-gpu=index,name,uuid,serial-- format=csvindex, name,uuid, serial0, Tesla P4, GPU-fa974b1d-3c17-ed92-28d0-805c6d089601, 0325017070224

To be verified, because I do not have a GPU machine now-has been verified, according to the above operation, you can successfully drive the nvidia video card in docker.

Thank you for reading! This is the end of the article on "how docker19.03 uses NVIDIA graphics card". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report