安裝相關(guān)包
$ 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.