之前写的[笔记] Ubuntu 18.04安装Docker CE及nvidia-docker2流程已经out了,以这篇为准。

Docker的好处之一,就是在Container里面可以随意瞎搞,不用担心弄崩Host的环境。

为了在docker中支持GPU,NVidia之前是弄了个nvidia-docker2,现在升级为NVIDIA Container Toolkit了。官方说法是"Usage of nvidia-docker2 packages are deprecated since NVIDIA GPUs are now natively supported as devices in the Docker runtime"。

安装环境

  • OS:Ubuntu 18.04 64 bit
  • 显卡:NVidia GTX 2080 Ti x 2
  • CUDA:10.0
  • cnDNN:7.4

任务:安装Docker CENVIDIA Container Toolkit,以便后期开展深度学习

配置Docker源

# 更新源
$ sudo apt update # 启用HTTPS
$ sudo apt install -y \
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

此刻Docker版本需要19.03,此后可能需要更新。

# 更新源
$ sudo apt update # 安装Docker CE
$ sudo apt install -y docker-ce

如果这种方式安装失败,也有解决方案。

报错时屏幕上会显示下载失败的deb文件,想办法下载下来,然后挨个手动安装就好。

此刻我需要下载的是下面三个文件,此后更新为当时最新版本即可:

手动依次安装:

$ sudo dpkg -i containerd.io_1.2.6-3_amd64.deb
$ sudo dpkg -i docker-ce-cli_19.03.0~3-0~ubuntu-bionic_amd64.deb
$ sudo dpkg -i docker-ce_19.03.0~3-0~ubuntu-bionic_amd64.deb

验证Docker CE

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

$ 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-docker

# 添加源
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list # 安装并重启docker
$ sudo apt update && sudo apt install -y nvidia-container-toolkit
$ sudo systemctl restart docker

使用

# 在官方CUDA镜像上测试 nvidia-smi
$ sudo docker run --gpus all nvidia/cuda:9.0-base nvidia-smi # 启动支持双GPU的容器
$ sudo docker run --gpus 2 nvidia/cuda:9.0-base nvidia-smi # 指定GPU 1,运行容器
$ sudo docker run --gpus device=0 nvidia/cuda:9.0-base nvidia-smi

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

[笔记] Ubuntu 18.04安装Docker CE及NVIDIA Container Toolkit流程的更多相关文章

  1. [笔记] Ubuntu 18.04安装Docker CE及nvidia-docker2流程

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

  2. [笔记] Ubuntu 18.04安装cuda 10及cudnn 7流程

    安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 任务:安装 CUDA 10及cuDNN 7 工具下载 NVidia官网下载下列文件: CUDA 10:cu ...

  3. 记录Ubuntu 16.04 安装Docker CE

    一.Docker的两个版本 Docker有两个版本: 社区版(CE) 企业版(EE) Docker Community Edition(CE)非常适合希望开始使用Docker并尝试使用基于容器的应用程 ...

  4. Ubuntu 18.04 安装 docker, 设置阿里云加速

    1.卸载旧的 docker 环境 sudo apt-get remove docker docker-engine docker.io containerd runc 2.设置仓库 更新索引 sudo ...

  5. ubuntu 18.04安装docker以及docker内配置neo4j

    如题 切换到root用户下 apt install docker.io 等啊等,很快,就好了.. 如图 即可使用 如果出现Cannot connect to the Docker daemon at ...

  6. Ubuntu 18.04 安装Docker

    第一种方法从Ubuntu的仓库直接下载安装: 安装比较简单,这种安装的Docker不是最新版本,不过对于学习够用了,依次执行下面命令进行安装. $ sudo apt install docker.io ...

  7. Ubuntu 18.04安装docker 以及Nginx服务设置

    1.安装需要的包sudo apt install apt-transport-https ca-certificates software-properties-common curl 2.添加 GP ...

  8. [笔记] Ubuntu 18.04源码安装caffe流程

    虽然Ubuntu 18.04可以通过apt安装caffe,但是为了使用最新的代码,还是值得从源码安装一遍的. 安装环境 OS: Ubuntu 18.04 64 bit 显卡: NVidia GTX 1 ...

  9. 笔记:在 Windows 10 WSL Ubuntu 18.04 安装 Odoo12 (2019-06-09)

    笔记:在 Windows 10 WSL Ubuntu 18.04 安装 Odoo12 原因 为了和服务器一样的运行环境. 使用 Ubuntu 运行 Odoo 运行更快. 方便使用 Windows 10 ...

随机推荐

  1. BZOJ 最大公约数 (通俗易懂&效率高&欧拉函数)

    题目 题目描述 给定整数\(N\),求\(1 \le x,y \le N\)且\(gcd(x,y)\)为素数的数对\((x,y)\)有多少对. \(gcd(x,y)\)即求\(x,y\)的最大公约数. ...

  2. netty-3.客户端与服务端通信

    (原) 第三篇,客户端与服务端通信 以下例子逻辑: 如果客户端连上服务端,服务端控制台就显示,XXX个客户端地址连接上线. 第一个客户端连接成功后,客户端控制台不显示信息,再有其它客户端再连接上线,则 ...

  3. 远程文件传输工具sftp、scp、rsync

    一.scp 格式 scp [options] [user@]host : /sourcefile /destpathscp [options] /sourcefile [user@]host:/des ...

  4. ZJOI2013 K大数查询 和 LG3380【模板】二逼平衡树(树套树)

    K大数查询 有N个位置,M个操作.操作有两种,每次操作如果是1 a b c的形式表示在第a个位置到第b个位置,每个位置加入一个数c:如果是2 a b c形式,表示询问从第a个位置到第b个位置,第C大的 ...

  5. BZOJ3589 动态树[树剖/暴力/容斥]

    操作0,显然直接线段树解决. 操作1,瓶颈在于重叠的链只算一次.在线段树上来看,如果一个区间被覆盖了,那么只算这个区间,子树里面也就不管了. 考虑对节点打标记来表示是否覆盖.但是,如果统一打完之后,并 ...

  6. nginx之"/"结尾

    一.配置127.0.0.1:8081的tomcat下的文件: 1.ROOT/a.html : this is ROOT page 2.ROOT/testa.html : nihao 3.ROOT/in ...

  7. Eclipse指定jdk启动

    在eclipse.ini文件中加入这一句话: -vm D:/Java/jdk/jdk1.8/jre/bin/server/jvm.dll

  8. (已解决)FVDI 2018“连接到服务器.....失败”“打不开设备”

    FVDI 2018 错误和解决方案来自网站:eobdtool.co.uk FVDI 2018发现以下错误: “连接到服务器.....失败” “设备未打开” 解决方案: 请下载FDVI 2018 V3. ...

  9. JMS 重点是JMS消息结构讲解

    这部分之前认识的不是很清楚,转载记录下,转载自:https://www.cnblogs.com/Zender/p/9098410.html 阅读目录 一,消息服务 二,JMS 回到目录 小时(1000 ...

  10. nginx负载均衡 页面缓存

    nginx的upstream目前支持4种方式的分配 1.轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除. 2.weight 指定轮询几率,weight ...