在 Ubuntu 16.04 上安装Nidia-Docker
来源:互联网 发布:ps纸张纹理 知乎 编辑:程序博客网 时间:2024/06/13 00:14
在 Ubuntu 16.04 上安装Nidia-Docker
Docker CE 的安装
由于 Ubuntu 源里的docker版本太老,建议根据官方教程安装
这是2017年12月24日根据docker官方文档记录的,省略了一些步骤,仅供参考,如果安装失败,建议您查看官方文档
Set up the repository
1.Upadate apt
package index:
$ sudo apt-get update
2.Install packages to allow apt
to use a repository over HTTPS:
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common
3.Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid Docker Release (CE deb) <docker@docker.com>sub 4096R/F273FCD8 2017-02-22
4.Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
Install Docker CE
$ sudo apt-get install docker-ce
Verify that Docker CE is installed correctly by running the hello-world image
$ sudo docker run hello-world
执行这条命令后,如果本地没有这个 image ,会连接官方的 Docker Hub 进行下载,连接会花费一点时间,如果网络状况不好可以更改国内的镜像或使用加速器
Nvidia-Docker 的安装
GitHub:https://github.com/NVIDIA/nvidia-docker
Make sure you have installed the NVIDIA driver and a supported version of Docker for your distribution (see prerequisites).
If you have a custom /etc/docker/daemon.json, the nvidia-docker2 package might override it.
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containersdocker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -fsudo apt-get purge -y nvidia-docker# Add the package repositoriescurl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ sudo apt-key add -curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \ sudo tee /etc/apt/sources.list.d/nvidia-docker.listsudo apt-get update# Install nvidia-docker2 and reload the Docker daemon configurationsudo apt-get install -y nvidia-docker2sudo pkill -SIGHUP dockerd# Test nvidia-smi with the latest official CUDA imagedocker run --runtime=nvidia --rm nvidia/cuda nvidia-smi