背景

  • NVIDIA-container-runtime是在docker容器中映射本机显卡必备的运行时
  • NVIDIA推出该工具之后搭配新版本的docker就不需要使用单独版本的docker启动支持显卡的容器

开始动手

添加安装源

官网比较难进,酌情查看

Debian-based distributions

Debian/Ubuntu/…

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

RHEL-based distributions

CentOS/Fedora/Oracle/…

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.repo | \
  sudo tee /etc/yum.repos.d/nvidia-container-runtime.repo

更新密钥

安装源来自于nvidia官网,可能会有些慢

Debian-based distributions

curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
  sudo apt-key add -

RHEL-based distributions

DIST=$(sed -n 's/releasever=//p' /etc/yum.conf)
DIST=${DIST:-$(. /etc/os-release; echo $VERSION_ID)}
sudo rpm -e gpg-pubkey-f796ecb0
sudo gpg --homedir /var/lib/yum/repos/$(uname -m)/$DIST/nvidia-container-runtime/gpgdir --delete-key f796ecb0

安装

安装源来自于nvidia官网,可能会有些慢

Debian-based distributions

sudo apt-get install nvidia-container-runtime

RHEL-based distributions

sudo yum install nvidia-container-runtime

参考