這篇博客的起因是在docker容器中引入GPU資源時(shí),查閱了網(wǎng)上許多教程,教程之間概念模糊不清,相互矛盾,過(guò)時(shí)的教程和新的教程混雜在一起。主要原因是nvidia為docker容器的支持發(fā)生了好幾代變更,api發(fā)生了不少變化。下面來(lái)總結(jié)一下各代支持發(fā)展歷程。
省流版總結(jié)
凡是使用了命令nvidia docker
或者在docker中引入了--runtime=nvidia
參數(shù)的都是過(guò)時(shí)教程,最新方法只需要下載nvidia-container-toolkits
,在docker中引入--gpus
參數(shù)即可。
nvidia docker
nvidia docker是NVIDIA第一代支持docker容器內(nèi)使用GPU資源的項(xiàng)目。運(yùn)行時(shí)用nvidia-docker
命令。
根據(jù)nvidia docker在github上的描述,已經(jīng)不再使用了。
The nvidia-docker wrapper script that was included in this repository is no longer included in the package and a configuration specific to the target container engine (e.g. Docker, Containerd, Cri-o, or Podman) is suggested instead.
nvidia docker2
nvidia docker2是NVIDIA第二代支持docker容器內(nèi)使用GPU資源的項(xiàng)目。運(yùn)行時(shí)用nvidia-docker
命令,且需要指定參數(shù)--runtime=nvidia
.
根據(jù)github wiki的描述,一代和二代之間有如下兼容性。
Backward compatibility To help transitioning code from 1.0 to 2.0, a bash script is provided in /usr/bin/nvidia-docker for backward compatibility. It will automatically inject the --runtime=nvidia argument and convert NV_GPU to NVIDIA_VISIBLE_DEVICES.
也就是說(shuō),在二代中,既可以使用nvidia docker
命令,這會(huì)自動(dòng)引入?yún)?shù)--runtime=nvidia
也可以使用docker
命令,手動(dòng)指定參數(shù)--runtime=nvidia
如帖子總結(jié):
docker run --runtime=nvidia is only available since nvidia-docker v2.
Both commands are equivalent with nvidia-docker v2, the former is a script provided for backward compatibility with nvidia-docker v1.文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-778845.html
nvidia-container-toolkits
根據(jù)github這是最新的支持方案,如帖子描述,nvidia docker2 被Nvidia container toolkits取代,無(wú)需指定--runtime
參數(shù),只需要傳遞--gpus
參數(shù)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-778845.html
到了這里,關(guān)于nvidia docker, nvidia docker2, nvidia container toolkits三者的區(qū)別的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!