2024年9月北京docker安装+nvidia-docker

发布于:2024-09-18 ⋅ 阅读:(74) ⋅ 点赞:(0)

使用docker.doscs中的manuals说明安装,链接如下
https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository

步骤一使用aptapt安装
使用apt安装
Install using the apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
首次安装docker,否则要先进行docker卸载

  1. Set up Docker’s apt repository.
    添加库
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
  1. Install the Docker packages.
    安装docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Verify that the Docker Engine installation is successful by running the hello-world image.
    验证是否成功
sudo docker run hello-world

进一步需要安装nvidia-docker的话

步骤二:安装NVIDIA Container Toolkit
接下来,您需要安装NVIDIA Container Toolkit,它包含了Nvidia-Docker的必要组件。使用以下命令进行安装:


sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

步骤三:测试Nvidia-Docker
最后,运行以下命令来测试Nvidia-Docker是否成功安装:

docker run --rm --gpus all nvidia/cuda:10.0-base nvidia-smi