安装docker&nvidia-docker
2019-07-09 本文已影响0人
乘瓠散人
Ubuntu18.04环境
安装docker
-
下载安装包
wget -qO- https://get.docker.com/ | sh
-
使非root用户可以直接运行docker
sudo usermod -aG docker luobu
然后退出再重新登录。 -
测试
docker run hello-world
- 卸载旧版本docker:
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt autoremove
安装nvidia-docker
主要参见官方教程nvidia-docker,更清楚。
# 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:9.0-base nvidia-smi
参考:
https://www.jianshu.com/p/e64ecf2f6f26
https://www.runoob.com/docker/ubuntu-docker-install.html
https://github.com/NVIDIA/nvidia-docker/