ubuntu16.04安装docker、nvidia-docker2、docker-compose、nvidia-driver
#1.install docker
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common && curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - && sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" && sudo apt-get install -y docker-ce=5:18.09.6~3-0~ubuntu-xenial && #apt-cache madison docker-ce可查看对应版本
sudo gpasswd -a $USER docker && newgrp docker
#2.install nvidia-docker(有nvidia-docker2才支持cuda10)
curl -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 && sudo apt-get update && sudo apt-get install -y nvidia-docker2 && sudo pkill -SIGHUP dockerd
#3.install docker-compose(nvidia-docker2不支持nvidia-docker-compose,目前只能用docker-compose取代,通过配置daemon.json:default-runtime=nvidia)
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
#5.install nvidia-driver
sudo add-apt-repository ppa:graphics-drivers && sudo apt-get update && sudo apt-get install -y nvidia-418 nvidia-settings nvidia-prime && nvidia-smi