如果之前安装过docker1.0版本,需要先删掉该版本和之前创建的容器
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
添加代码仓库
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
安装docker 2
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
测试
docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi