Tensorflow with CUDA/cuDNN on Ubuntu 16.04

tf-cuda-cudnn

Environment:

  • OS: Ubuntu 16.0
  • Python 2.7
  • CUDA 8.0.27
  • CuDNN v5.1
  • Note: TensorFlow with GPU support, both NVIDIA’s Cuda Toolkit (>= 7.0) and cuDNN (>= v3) need to be installed.

GPU verification:

$ nvidia-smi
Tue Nov 22 04:28:59 2016
+-------------------------------------------------------------+
| NVIDIA-SMI 370.28 Driver Version: 370.28 |
|---------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|====================+======================+======================|
| 0 GRID K520 Off | 0000:00:03.0 Off | N/A |
| N/A 43C P0 1W / 125W | 0MiB / 4036MiB | 0% Default |
+----------------------+----------------------+---------------+

+-------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|===============================================================|
| No running processes found |
+--------------------------------------------------------------+

CUDA Toolkit verification:

$cat /usr/local/cuda/version.txt
CUDA Version 8.0.27

CuDNN Verification:

Download cudnn-8.0-linux-x64-v5.1.tgz from Nvidia developer site.

  • $ tar -xvzf cudnn-8.0-linux-x64-v5.1.tgz
  •  ## NOTE: unzip happens at local cuda folder
  • cuda
    • include/
      • cudnn.h
    • lib64/
      • libcudnn.so -> libcudnn.so.5*
      • libcudnn.so.5 -> libcudnn.so.5.1.5*
      • libcudnn.so.5.1.5*

You just need to merge cuDNN cudnn.h and lib64 files to cuda toolkit at /usr/bin/cuda as below:

sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Setting cuda libraries into path:

export PATH=${PATH}:/usr/local/cuda/bin

Tensorflow Install:

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl
$ sudo pip install –upgrade $TF_BINARY_URL

Tensorflow Verification:

>>> import tensorflow as tf

I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
>>>

Have fun !!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s