安装 cuda 驱动和 nvidia-container-tookit

Ubuntu Install docker

apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -

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

apt-get update

apt-get install docker-ce=5:19.03.6~3-0~ubuntu-"$(lsb_release -cs)" docker-ce-cli=5:19.03.6~3-0~ubuntu-"$(lsb_release -cs)" -qq -y

systemctl enable docker

systemctl start docker

docker version

Ubuntu Install cuda / nvidia-docker

# Ubuntu16.04
curl -fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu1604/x86_64/7fa2af80.pub | apt-key add -
echo "deb https://mirrors.aliyun.com/nvidia-cuda/ubuntu1604/x86_64/ ./" > /etc/apt/sources.list.d/cuda.list

# Ubuntu18.04
curl -fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/7fa2af80.pub | apt-key add -
echo "deb https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/ ./" > /etc/apt/sources.list.d/cuda.list

apt-get update && apt-get install -y cuda-drivers-460

curl -sSL https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -

# Ubuntu16.04
curl -sSL -o /etc/apt/sources.list.d/nvidia-docker.list https://nvidia.github.io/nvidia-docker/ubuntu16.04/nvidia-docker.list

# Ubuntu18.04
curl -sSL -o /etc/apt/sources.list.d/nvidia-docker.list https://nvidia.github.io/nvidia-docker/ubuntu18.04/nvidia-docker.list

apt update && apt-get install -y nvidia-container-toolkit

reboot

nvidia-smi

CentOS7 Install cuda / nvidia-docker

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
   && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
yum clean expire-cache
yum install -y nvidia-docker2
systemctl restart docker

yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
yum clean all
yum -y install nvidia-driver-latest-dkms cuda
yum -y install cuda-drivers

# 如果遇到下面的错误可按照下面的步骤解决
# Can not use nvidia-container-runtime repository - repomod.xml signature could not be verified

gpg --homedir /var/lib/yum/repos/x86_64/7/libnvidia-container/gpgdir --delete-key F796ECB0
gpg --homedir /var/lib/yum/repos/x86_64/7/nvidia-container-runtime/gpgdir --delete-key F796ECB0
gpg --homedir /var/lib/yum/repos/x86_64/7/nvidia-docker/gpgdir --delete-key F796ECB0
yum update

 

posted @ 2021-04-25 21:48  运维工作栈  阅读(576)  评论(0)    收藏  举报