安装相关包
$ sudo apt-get update# 先更新一下软件源库信息
$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
添加软件仓库
官方仓库
# 添加 Docker 官方的 GPG 密钥(为了确认所下载软件包的合法性,需要添加软件源的 GPG 密钥)
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
阿里云仓库
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
安装docker
$ sudo apt-get update
$ sudo apt-get install docker-ce # 安装最新版的docker
# 检查docker是否安装成功
$ docker --version# 查看安装的docker版本
运行docker测试
这个时候就可以运行helloworld测试啦~
$ docker run hello-world
到这里就安装完成docker
Make sure you have installed theNVIDIA driverand Docker 19.03 for your Linux distribution
For first-time users of Docker 19.03 and GPUs, continue with the instructions for getting started below.
Ubuntu 16.04/18.04, Debian Jessie/Stretch
#Add the package repositories
$ 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
$ sudo apt-get update&&sudo apt-get install -y nvidia-container-toolkit
$ sudo systemctl restart docker
Usage:
#### Test nvidia-smi with the latest official CUDA image
$ sudo docker run --gpus all nvidia/cuda:9.0-base nvidia-smi
but access dockerhub is very difficult in china, so i gave up.