1. 程式人生 > >Ubuntu 14.04/16.04/18.04安裝nvidia-docker2

Ubuntu 14.04/16.04/18.04安裝nvidia-docker2

一.安裝NVIDIA驅動

二.安裝CUDA(可選)

見:Ubuntu 16.04安裝Cuda8.0
注意,需要--no-opengl-libs字尾,並且該步驟就不需要再重複安裝nvidia驅動了。

三.安裝docker

sudo apt-get remove docker docker-engine docker.io  #全新安裝時,無需執行該步驟

sudo apt-get update 

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

curl -fsSL https
://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" sudo apt-get update sudo apt-get install docker-ce

四.docker免sudo

sudo groupadd docker

sudo gpasswd -a ${USER} docker

sudo
service docker restart newgrp - docker

五.安裝nvidia-docker2

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
#全新安裝時,無需執行該步驟
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ sudo apt-key add - 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 sudo apt-get update # Install nvidia-docker2 and reload the Docker daemon configuration sudo apt-get install -y nvidia-docker2 sudo pkill -SIGHUP dockerd # Test nvidia-smi with the latest official CUDA image docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi