久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

docker19.03如何使用NVIDIA顯卡

221次閱讀
沒有評論

共計 6164 個字符,預(yù)計需要花費 16 分鐘才能閱讀完成。

這篇文章給大家分享的是有關(guān) docker19.03 如何使用 NVIDIA 顯卡的內(nèi)容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。

docker19.03 使用 NVIDIA 顯卡前言

2019 年 7 月的 docker 19.03 已經(jīng)正式發(fā)布了,這次發(fā)布對我來說有兩大亮點。
1,就是 docker 不需要 root 權(quán)限來啟動喝運行了
2,就是支持 GPU 的增強功能,我們在 docker 里面想讀取 nvidia 顯卡再也不需要額外的安裝 nvidia-docker 了

安裝 nvidia 驅(qū)動

確認已檢測到 NVIDIA 卡:

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

這里不再詳細介紹:如果不知道請移步 ubuntu 離線安裝 TTS 服務(wù)

安裝 NVIDIA Container Runtime

$ cat nvidia-container-runtime-script.sh
curl -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.list
sudo apt-get update

執(zhí)行腳本

sh nvidia-container-runtime-script.sh
OK
deb 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 InRelease
Get: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 InRelease
Hit:8 http://us-east4-c.gce.clouds.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:9 http://us-east4-c.gce.clouds.archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 9435 B in 1s (17.8 kB/s) 
Reading package lists... Done
$ apt-get install nvidia-container-runtime
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages were automatically installed and are no longer required:
 grub-pc-bin libnuma1
Use  sudo apt autoremove  to remove 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

安裝 docker-19.03

# step 1:  安裝必要的一些系統(tǒng)工具
yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2:  添加軟件源信息
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3:  更新并安裝  Docker-CE
yum makecache fast
yum -y install docker-ce-19.03.2
# Step 4:  開啟 Docker 服務(wù)
systemctl start docker   systemctl enable docker

驗證 docker 版本是否安裝正常

$ docker version
Client: 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: false
Server: 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

驗證下 -gpus 選項

$ docker run --help | grep -i gpus
 --gpus gpu-request GPU devices to add to the container (all  to pass all GPUs)

運行利用 GPU 的 Ubuntu 容器

 $ docker run -it --rm --gpus all ubuntu nvidia-smi
Unable to find image  ubuntu:latest  locally
latest: Pulling from library/ubuntu
f476d66f5408: Pull complete 
8882c27f669e: Pull complete 
d9af21273955: Pull complete 
f5029279ec12: Pull complete 
Digest: sha256:d26d529daa4d8567167181d9d569f2a85da3c5ecaf539cace2c6223355d69981
Status: Downloaded newer image for ubuntu:latest
Tue 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 | 00000000:00:04.0 Off | 0 |
| N/A 39C P0 22W / 75W | 0MiB / 7611MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
:~$

故障排除

您是否遇到以下錯誤消息:

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

上述錯誤意味著 Nvidia 無法正確注冊 Docker。它實際上意味著驅(qū)動程序未正確安裝在主機上。這也可能意味著安裝了 nvidia 容器工具而無需重新啟動 docker 守護程序:您需要重新啟動 docker 守護程序。

我建議你回去驗證是否安裝了 nvidia-container-runtime 或者重新啟動 Docker 守護進程。

列出 GPU 設(shè)備

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

待驗證,因為我現(xiàn)在沒有 GPU 機器 — 已經(jīng)驗證完成,按照上述操作可以在 docker 里面成功的驅(qū)動 nvidia 顯卡

感謝各位的閱讀!關(guān)于“docker19.03 如何使用 NVIDIA 顯卡”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-25發(fā)表,共計6164字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 资源县| 孟州市| 开阳县| 武夷山市| 承德县| 石渠县| 塘沽区| 黄大仙区| 土默特右旗| 西华县| 南华县| 林甸县| 定陶县| 故城县| 长春市| 瑞金市| 平阴县| 江陵县| 延寿县| 海阳市| 瑞昌市| 阿克苏市| 堆龙德庆县| 长沙市| 江山市| 通海县| 丹东市| 昭苏县| 岢岚县| 广水市| 田阳县| 朝阳区| 涞源县| 临沧市| 内丘县| 镇原县| 隆回县| 丹凤县| 通化县| 鹰潭市| 称多县|