Ubuntu16.04如何安装Docker、nvidia-docker

2023-04-19 07:04:00 nvidia 安装 ubuntu16

Ubuntu16.04安装Docker和nvidia-docker的过程如下:

一、安装Docker

1. 在安装之前,先更新系统软件包:

sudo apt-get update

2. 安装Docker需要的依赖包:

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

3. 添加Docker的官方GPG密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4. 添加Docker的软件源:

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

5. 更新软件包:

sudo apt-get update

6. 安装Docker:

sudo apt-get install docker-ce

7. 启动Docker服务:

sudo systemctl start docker

8. 验证是否安装成功:

sudo docker run hello-world

二、安装nvidia-docker

1. 安装nvidia-docker的依赖包:

sudo apt-get install -y nvidia-modprobe

2. 添加nvidia-docker的官方GPG密钥:

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -

3. 添加nvidia-docker的软件源:

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

4. 更新软件包:

sudo apt-get update

5. 安装nvidia-docker:

sudo apt-get install -y nvidia-docker2

6. 重启Docker服务:

sudo systemctl restart docker

7. 验证是否安装成功:

sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

相关文章