docker 和nvidia-docker安装

#!/bin/bash

sudo apt install curl

curl https://get.docker.com | sh \
&& sudo systemctl start docker \
&& sudo systemctl enable docker


# Requires nvidia docker - https://github.com/NVIDIA/nvidia-docker
if ! $(apt list --installed | grep -q nvidia-container-toolkit); then
  read -p "Nvidia docker is required. Do you want to install it now? (y/n)";
  if [ "${REPLY}" == "y" ]; then
    distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    echo $distribution
    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-docker2 # Also installs docker-ce and nvidia-container-toolkit
    sudo systemctl restart docker
  else
    exit 0
  fi
fi
posted @ 2022-09-04 13:29  hiccup_lh  阅读(69)  评论(0编辑  收藏  举报