背景
需求:实验室内通过Docker搭建隔离环境保证各用户数据安全和服务器环境安全,防止软件环境混杂造成莫名其妙的bug,容器内需要能够调用显卡资源。
预先准备
本文的内容基于以下软件版本:
Docker:Docker version 20.10.17, build 100c701
CUDA:NVIDIA-SMI 510.68.02 Driver Version: 510.68.02 CUDA Version: 11.6
系统:Ubuntu 20.04.4 LTS
Nvidia-container-toolkit架构
Nvidia官网架构概述,可以用Chrome自带网页翻译仔细阅读,本文仅简单介绍。
架构
The NVIDIA container stack is architected so that it can be targeted to support any container runtime in the ecosystem.
The components of the stack include:
The nvidia-docker wrapper
The NVIDIA Container Runtime (nvidia-container-runtime)
The NVIDIA Container Runtime Hook (nvidia-container-toolkit / nvidia-container-runtime-hook)
The NVIDIA Container Library and CLI (libnvidia-container1, nvidia-container-cli)
...
Note that as of version 3.6.0, the nvidia-container-runtime package is a meta package that
only depends on the nvidia-container-toolkit package and does not provide any functionality of itself.
NVIDIA container主要组件包括nvidia-container-runtime
, nvidia-container-toolkit
, libnvidia-container
和CUDA
驱动;
在3.6.0版本后,runtime包成为一个只依赖于toolkit包(指container-toolkit而不是nvidia CUDA toolkit)的包,在官网中也指出&#