目录
1. Tensorflow GPU 安装
我的机器是 Thinkpad T480, 操作系统是 Ubuntu 18.04 LTS, 显卡 NVIDIA MX150 是支持 CUDA 的。Tensorflow 官方推荐使用 Docker 安装 TensorFlow GPU。
TensorFlow GPU support requires an assortment of drivers and libraries. To simplify installation and avoid library conflicts, we recommend using a TensorFlow Docker image with GPU support (Linux only). This setup only requires the NVIDIA® GPU drivers
Docker uses containers to create virtual environments that isolate a TensorFlow installation from the rest of the system. TensorFlow programs are run within this virtual environment that can share resources with its host machine (access directories, use the GPU, connect to the Internet, etc.). The TensorFlow Docker images are tested for each release.
Docker is the easiest way to enable TensorFlow GPU support on Linux since only the NVIDIA® GPU driver is required on the host machine (the NVIDIA® CUDA® Toolkit does not need to be installed).
1.1. 安装 NVIDIA 显卡驱动
我们建议使用官方源自动安装, 其他安装方法可以参考 How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux
1 | $ sudo apt-get update |
如果 nvidia-smi 报错:
NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
进入 BIOS 将 Secure Boot 改成 Disable。重新登录系统可以看到:
1 | $ nvidia-smi |
1.2. 安装 Docker
参考 Docker 官网教程 Get Docker CE for Ubuntu
1.3. 安装 nvidia-drivers
参考 github.com/NVIDIA/nvidia-docker
1 | # If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers |
1.4. 启动 Tensorflow GPU Docker 镜像
1 | # 下载 docker 镜像, 标签 latest-devel-gpu-py3 表示该镜像包含 GPU, Python 3 和源代码。 |
进入 bash 后, 执行 Python 代码
1 | $ python |
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
1 | import os |
1.5. 登录 Jupyter Notebook 页面
我运行 latest-devel-gpu-py3 镜像时,登录 http://localhost:8888/ 一直提示 This site can’t be reached。后来下载了默认镜像,结果就能正常登录,不清楚是不是 latest-devel-gpu-py3 这个镜像不支持 Jupyter Notebook。
1 | $ docker pull tensorflow/tensorflow |
现在,打开浏览器输入 http://localhost:8888/ 即可进入 Jupyter Notebook 页面。
2. Tensorflow 入门
2.1. 深度学习入门
2.2. Ten搜人flow 架构

(未完待续…)