前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ubuntu 18.04安装Docker CE及nvidia-docker2流程

Ubuntu 18.04安装Docker CE及nvidia-docker2流程

作者头像
星哥玩云
发布2022-07-26 20:07:46
7910
发布2022-07-26 20:07:46
举报
文章被收录于专栏:开源部署

Docker的好处之一,就是在Container里面可以随意瞎搞,不用担心弄崩Host的环境。 而nvidia-docker2的好处是NVidia帮你配好了Host和Container之间的CUDA相关的链接,让你可以直接在Container里面使用GPU。

NVIDIA Container Runtime for Docker
NVIDIA Container Runtime for Docker

安装环境

  • OS:Ubuntu 18.04 64 bit
  • 显卡:NVidia GTX 1080
  • CUDA:10.0
  • cnDNN:7.4

任务:安装Docker CEnvidia-docker2,以便后期开展深度学习

配置Docker源

代码语言:javascript
复制
# 更新源
$ sudo apt-get update

# 启用HTTPS
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

# 添加GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# 添加稳定版的源
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

安装Docker CE

代码语言:javascript
复制
# 更新源
$ sudo apt-get update

# 安装Docker CE
$ sudo apt-get install docker-ce

如果这种方式安装失败,也有解决方案。 报错时屏幕上会显示下载失败的deb文件,想办法下载下来,然后挨个手动安装就好。

此时我需要下载的是下面三个文件:

  • containerd.io_1.2.2-1_amd64.deb
  • docker-ce-cli_18.09.1~3-0~ubuntu-bionic_amd64.deb
  • docker-ce_18.09.1~3-0~ubuntu-bionic_amd64.deb

手动依次安装:

代码语言:javascript
复制
$ sudo dpkg -i containerd.io_1.2.2-1_amd64.deb
$ sudo dpkg -i docker-ce-cli_18.09.1~3-0~ubuntu-bionic_amd64.deb
$ sudo dpkg -i docker-ce_18.09.1~3-0~ubuntu-bionic_amd64.deb

验证Docker CE

如果出现下面的内容,说明安装成功。

代码语言:javascript
复制
$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

配置nvidia-docker2

代码语言:javascript
复制
# 添加源
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list

安装nvidia-docker2

代码语言:javascript
复制
# 安装nvidia-docker2
$ sudo apt-get install -y nvidia-docker2

# 重启Docker daemon
$ sudo pkill -SIGHUP dockerd

验证nvidia-docker2

代码语言:javascript
复制
$ sudo nvidia-docker run --rm nvidia/cuda nvidia-smi

能看到显卡信息就说明OK了,当前image是基于Ubuntu 18.04的。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装环境
  • 配置Docker源
  • 安装Docker CE
  • 验证Docker CE
  • 配置nvidia-docker2源
  • 安装nvidia-docker2
  • 验证nvidia-docker2
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档