安装Docker和Nvidia-Docker
2019-05-05 本文已影响0人
shenghaishxt
本文来自我的个人博客 https://www.zhangshenghai.com/posts/35246/
安装Docker
Docker官方为了简化流程,提供了一套便捷的安装脚本,在Ubuntu上可以使用脚本自动安装Docker CE:
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
启动Docker CE:
sudo systemctl enable docker
sudo systemctl start docker
建立Docker用户组:
sudo groupadd docker
sudo usermod -aG docker $USER
测试Docker是否安装正确:
docker run hello-world
安装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 yum remove nvidia-docker
# Add the package repositories
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
# Install nvidia-docker2 and reload the Docker daemon configuration
sudo yum 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