安装 nvidia-container-toolkit 以支持 docker 使用显卡

引言如果在 docker 中使用 gpu 时,遇到以下错误:
代码语言:bash复制```bash docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
你可以按照以下步骤安装 nvidia-container-toolkit 来支持 docker 使用显卡。 <p>官方网站地址:</p><p>Installing the NVIDIA Container Toolkit — NVIDIA Container Toolkit 1.16.2 documentation</p><p>步骤使用 Yum 或 Dnf 进行安装配置生产仓库:</p><p>代码语言:bash<svg fill="none" height="16" viewbox="0 0 16 16" width="16" xmlns="<a href="https://www.php.cn/link/c9041cfd2a40932691855abd98fd219a">http://www.w3.org/2000/svg"><path</a> clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor" fill-rule="evenodd"></path></svg>复制<code>bash curl -s -L <https:> | \sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo</https:></code>
可选地,配置仓库以使用实验性包:
代码语言:bash复制bash sudo yum-config-manager --enable nvidia-container-toolkit-experimental
<code> 安装 NVIDIA Container Toolkit 包:</p><p>代码语言:bash<svg fill="none" height="16" viewbox="0 0 16 16" width="16" xmlns="<a href="https://www.php.cn/link/c9041cfd2a40932691855abd98fd219a">http://www.w3.org/2000/svg"><path</a> clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor" fill-rule="evenodd"></path></svg>复制```bash</p> <div class="aritcle_card"> <a class="aritcle_card_img" href="/ai/2394"> <img src="https://img.php.cn/upload/ai_manual/001/246/273/176360889719039.png" alt="灵光"> </a> <div class="aritcle_card_info"> <a href="/ai/2394">灵光</a> <p>蚂蚁集团推出的全模态AI助手</p> <div class=""> <img src="/static/images/card_xiazai.png" alt="灵光"> <span>1635</span> </div> </div> <a href="/ai/2394" class="aritcle_card_btn"> <span>查看详情</span> <img src="/static/images/cardxiayige-3.png" alt="灵光"> </a> </div> <h1>更新仓库sudo dnf clean allsudo dnf makecache# 安装 NVIDIA Container Toolkitsudo dnf install -y nvidia-container-toolkit
使用 nvidia-ctk 命令配置容器运行时:
代码语言:bash复制```bash
sudo nvidia-ctk runtime configure --runtime=docker
重启 Docker 守护进程:</p><p>代码语言:bash<svg fill="none" height="16" viewbox="0 0 16 16" width="16" xmlns="<a href="https://www.php.cn/link/c9041cfd2a40932691855abd98fd219a">http://www.w3.org/2000/svg"><path</a> clip-rule="evenodd" d="M4.5 15.5V3.5H14.5V15.5H4.5ZM12.5 5.5H6.5V13.5H12.5V5.5ZM9.5 2.5H3.5V12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor" fill-rule="evenodd"></path></svg>复制```bash sudo systemctl restart docker
结论引用docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]]. AFTER installing nvidia-docker2 - Stack Overflow
以上就是安装 nvidia-container-toolkit 以支持 docker 使用显卡的详细内容,更多请关注其它相关文章!

12.5H1.5V0.5H11.5V2.5H9.5Z" fill="currentcolor" fill-rule="evenodd"></path></svg>复制```bash</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/2394">
<img src="https://img.php.cn/upload/ai_manual/001/246/273/176360889719039.png" alt="灵光">
</a>
<div class="aritcle_card_info">
<a href="/ai/2394">灵光</a>
<p>蚂蚁集团推出的全模态AI助手</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="灵光">
<span>1635</span>
</div>
</div>
<a href="/ai/2394" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="灵光">
</a>
</div>
<h1>更新仓库sudo dnf clean allsudo dnf makecache# 安装 NVIDIA Container Toolkitsudo dnf install -y nvidia-container-toolkit