欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Docker使用GPU全過程

 更新時(shí)間:2024年01月09日 15:16:25   作者:DripBoy  
這篇文章主要介紹了Docker使用GPU全過程,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

一、docker使用宿主機(jī)硬件設(shè)備的三種方式

  • 使用--privileged=true選項(xiàng),以特權(quán)模式開啟容器
  • 使用--device選項(xiàng)
  • 使用容器卷掛載-v選項(xiàng)

二、docker使用gpu方式演變

docker使用宿主機(jī)的gpu設(shè)備,本質(zhì)是把宿主機(jī)使用gpu時(shí)調(diào)用的設(shè)備文件全部掛載到docker上。

nvidia提供了三種方式的演變,如下是官網(wǎng)的一些介紹

來自 <Enabling GPUs in the Container Runtime Ecosystem | NVIDIA Technical Blog>

NVIDIA designed NVIDIA-Docker in 2016 to enable portability in Docker images that leverage NVIDIA GPUs. It allowed driver agnostic CUDA images and provided a Docker command line wrapper that mounted the user mode components of the driver and the GPU device files into the container at launch. Over the lifecycle of NVIDIA-Docker, we realized the architecture lacked flexibility for a few reasons: Tight integration with Docker did not allow support of other container technologies such as LXC, CRI-O, and other runtimes in the future We wanted to leverage other tools in the Docker ecosystem – e.g. Compose (for managing applications that are composed of multiple containers) Support GPUs as a first-class resource in orchestrators such as Kubernetes and Swarm Improve container runtime support for GPUs – esp. automatic detection of user-level NVIDIA driver libraries, NVIDIA kernel modules, device ordering, compatibility checks and GPU features such as graphics, video acceleration As a result, the redesigned NVIDIA-Docker moved the core runtime support for GPUs into a library called libnvidia-container. The library relies on Linux kernel primitives and is agnostic relative to the higher container runtime layers. This allows easy extension of GPU support into different container runtimes such as Docker, LXC and CRI-O. The library includes a command-line utility and also provides an API for integration into other runtimes in the future. The library, tools, and the layers we built to integrate into various runtimes are collectively called the NVIDIA Container Runtime. Since 2015, Docker has been donating key components of its container platform, starting with the Open Containers Initiative (OCI) specification and an implementation of the specification of a lightweight container runtime called runc. In late 2016, Docker also donated containerd, a daemon which manages the container lifecycle and wraps OCI/runc. The containerd daemon handles transfer of images, execution of containers (with runc), storage, and network management. It is designed to be embedded into larger systems such as Docker. More information on the project is available on the official site. Figure 1 shows how the libnvidia-container integrates into Docker, specifically at the runc layer. We use a custom OCI prestart hook called nvidia-container-runtime-hook to runc in order to enable GPU containers in Docker (more information about hooks can be found in the OCI runtime spec). The addition of the prestart hook to runc requires us to register a new OCI compatible runtime with Docker (using the –runtime option). At container creation time, the prestart hook checks whether the container is GPU-enabled (using environment variables) and uses the container runtime library to expose the NVIDIA GPUs to the container. Figure 1.Integration of NVIDIA Container Runtime with Docker

1、nvidia-docker

nvidia-docker是在docker的基礎(chǔ)上做了一層封裝

通過 nvidia-docker-plugin把硬件設(shè)備在docker的啟動(dòng)命令上添加必要的參數(shù)。

Ubuntu distributions 
# Install nvidia-docker and nvidia-docker-plugin 
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0-rc/nvidia-docker_1.0.0.rc-1_amd64.deb 
sudo dpkg -i /tmp/nvidia-docker_1.0.0.rc-1_amd64.deb && rm /tmp/nvidia-docker*.deb # Test nvidia-smi 
nvidia-docker run --rm nvidia/cuda nvidia-smi 
 
Other distributions 
# Install nvidia-docker and nvidia-docker-plugin 
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0-rc/nvidia-docker_1.0.0.rc_amd64.tar.xz 
sudo tar --strip-components=1 -C /usr/bin -xvf /tmp/nvidia-docker_1.0.0.rc_amd64.tar.xz && rm /tmp/nvidia-docker*.tar.xz 
# Run nvidia-docker-plugin 
sudo -b nohup nvidia-docker-plugin > /tmp/nvidia-docker.log 
# Test nvidia-smi 
nvidia-docker run --rm nvidia/cuda nvidia-smi 
 
Standalone install 
# Install nvidia-docker and nvidia-docker-plugin 
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.0-rc/nvidia-docker_1.0.0.rc_amd64.tar.xz 
sudo tar --strip-components=1 -C /usr/bin -xvf /tmp/nvidia-docker_1.0.0.rc_amd64.tar.xz && rm /tmp/nvidia-docker*.tar.xz 
# One-time setup 
sudo nvidia-docker volume setup 
# Test nvidia-smi 
nvidia-docker run --rm nvidia/cuda nvidia-smi

2、nvidia-docker2

sudo apt-get install nvidia-docker2 sudo apt-get install nvidia-container-runtime sudo dockerd --add-runtime=nvidia=/usr/bin/nvidia-container-runtime [...]

3、nvidia-container-toolkit

docker版本在19.03及以上后

nvidia-container-toolkit進(jìn)行了進(jìn)一步的封裝,在參數(shù)里直接使用--gpus "device=0" 即可

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 關(guān)于Docker容器Dead狀態(tài)的分析

    關(guān)于Docker容器Dead狀態(tài)的分析

    這篇文章主要介紹了關(guān)于Docker容器Dead狀態(tài)的分析,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • docker容器啟動(dòng)后如何修改或添加端口

    docker容器啟動(dòng)后如何修改或添加端口

    這篇文章主要介紹了docker容器啟動(dòng)后如何修改或添加端口問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • Docker容器網(wǎng)絡(luò)配置全攻略之橋接、Host、container詳解

    Docker容器網(wǎng)絡(luò)配置全攻略之橋接、Host、container詳解

    這篇文章主要介紹了Docker容器網(wǎng)絡(luò)配置全攻略之橋接、Host、container的使用,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-04-04
  • docker-compose ports和expose的區(qū)別詳解

    docker-compose ports和expose的區(qū)別詳解

    這篇文章主要介紹了docker-compose ports和expose的區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • k3d入門指南之在Docker中運(yùn)行K3s的詳細(xì)教程

    k3d入門指南之在Docker中運(yùn)行K3s的詳細(xì)教程

    在本文中,我們將簡單了解k3d,這是一款可讓您在安裝了Docker的任何地方運(yùn)行一次性Kubernetes集群的工具,此外在本文中我們還將探討在使用k3d中可能會(huì)出現(xiàn)的一切問題,感興趣的朋友跟隨小編一起看看吧
    2021-05-05
  • docker容器自動(dòng)退出重啟報(bào)錯(cuò)問題及解決

    docker容器自動(dòng)退出重啟報(bào)錯(cuò)問題及解決

    這篇文章主要介紹了docker容器自動(dòng)退出重啟報(bào)錯(cuò)問題及解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Docker之自定義網(wǎng)絡(luò)實(shí)現(xiàn)

    Docker之自定義網(wǎng)絡(luò)實(shí)現(xiàn)

    大家好,本篇文章主要講的是Docker之自定義網(wǎng)絡(luò)實(shí)現(xiàn),感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • Docker定制容器鏡像的2種方法(推薦)

    Docker定制容器鏡像的2種方法(推薦)

    本篇文章主要介紹了Docker定制容器鏡像的2種方法(推薦),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-02-02
  • docke自定義網(wǎng)絡(luò)之容器互聯(lián)

    docke自定義網(wǎng)絡(luò)之容器互聯(lián)

    大家好,本篇文章主要講的是docke自定義網(wǎng)絡(luò)之容器互聯(lián),感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • docker刪除鏡像的實(shí)現(xiàn)方式詳解

    docker刪除鏡像的實(shí)現(xiàn)方式詳解

    這篇文章主要為大家介紹了docker刪除鏡像的實(shí)現(xiàn)方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07

最新評(píng)論