用docker搭建tensorflow-gpu

参考文章https://tensorflow.google.cn/install/docker

1.安装docker

http://www.recommender.cn/2019/06/20/ubuntu%e5%ae%89%e8%a3%85docker/
安装nvidia驱动(参考https://zhuanlan.zhihu.com/p/65557545)
下载www.geforce.cn/drivers
安装(1)在/etc/modprobe.d/blacklist.conf中添加blacklist nouveau options nouveau modeset=0
(2)更新配置
 sudo update-initramfs -u
 重启
 reboot
 检测驱动是否禁止,无输出,则禁止成功
 lsmod | grep nouveau
(3)sudo service lightdm stop
 cd install_package
 sudo chmod 777 NVIDIA-Linux-x86_64-410.78.run
 sudo ./NVIDIA-Linux-x86_64-410.78.run

2.安装NVIDIA-docker

https://github.com/NVIDIA/nvidia-docker
(1)curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \   sudo apt-key add - 
(2)distribution=$(. /etc/os-release;echo $ID$VERSION_ID) 
(3)curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \   sudo tee /etc/apt/sources.list.d/nvidia-docker.list 
(4)sudo apt-get update 
(5)sudo apt-get install -y nvidia-docker2 
(6)sudo pkill -SIGHUP dockerd

3.配置docker daemon.json

{
     "default-runtime": "nvidia",
     "runtimes": {
         "nvidia": {
             "path": "nvidia-container-runtime",
             "runtimeArgs": []
         }
     },
     "registry-mirrors": ["http://f1361db2.m.daocloud.io"]
 }

4.安装tensorflow-gpu镜像

在这里找到镜像https://hub.daocloud.io/repos/4e686d90-5e24-40b1-8bc6-8616b82f8143
安装命令docker pull daocloud.io/daocloud/tensorflow:1.13.1-gpu-py3-jupyter
5.在pycharm中添加docker中的Python解释器
在python interpreter中选docker中的映像

你可能感兴趣的:(linux)