TensorFlow over docker with GPU support

I have succeeded to run TensorFlow on my desktop which runs Ubuntu 16.04 LTS with nVidia GeForce GTX 1050. I want to share the easy and fast way to install TensorFlow, so I write this down. This does NOT require to download and install CUDA toolkit nor cuDNN, but you can get GPU acceleration.

Prerequisite

Quick start

  1. install nvidia-docker.
  2. run TensorFlow using nvidia-docker.
    1
    sudo nvidia-docker run -it --rm -p 8888:8888 gcr.io/tensorflow/tensorflow:latest-gpu
  3. <ctrl>-click or copy & paste the URI looks like http://localhost:8888/?token=<hex_string> that appears on your terminal. Then you can get Jupyter notebook on your browser.

Why this works

nvidia-docker provides CUDA toolkit and cuDNN and tensorflow docker images utilizes it. All the installation procedures are abstracted by Docker images.

Troubleshooting in Ubuntu

  1. Identify your nVidia graphics card
    1
    $ lspci | grep -i nvidia
  2. Verify CUDA driver and its version
    1
    2
    3
    $ cat /proc/driver/nvidia/version
    NVRM version: NVIDIA UNIX x86_64 Kernel Module 375.39 Tue Jan 31 20:47:00 PST 2017
    GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
  3. Verify CUDA toolkit in nvidia-docker
    1
    $ sudo nvidia-docker run --rm nvidia/cuda nvidia-smi