読者です 読者をやめる 読者になる 読者になる

ubuntu14.04 LTS + CUDA + cuDNN + Tensorflow インストールメモ

tensorflow の動作確認まで

tensorflow

www.tensorflow.org

インストールガイド

Installing TensorFlow on Ubuntu  |  TensorFlow

インストール方法は何種類か有るらしいですが、We recommend the virtualenv installation. とのことなので、素直に従います。

インストー

$ sudo apt-get install python-virtualenv
$ mkdir ~/tensorflow
$ virtualenv --system-site-packages ~/tensorflow
New python executable in ***/tensorflow/bin/python
Installing setuptools, pip...done.

$ source ~/tensorflow/bin/activate
(tensorflow)$ pip install --upgrade tensorflow-gpu

失敗するので・・・

(tensorflow)$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp27-none-linux_x86_64.whl

ログがいっぱい出て・・・

Successfully installed tensorflow-gpu mock numpy protobuf wheel werkzeug funcsigs pbr setuptools
Cleaning up...

インストールのチェック validate the installation.

(tensorflow)$ deactivate

$ source ~/tensorflow/bin/activate

(tensorflow)$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-05-09 15:00:35.019097: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-09 15:00:35.019149: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-09 15:00:35.339102: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:901] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-05-09 15:00:35.339812: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties: 
name: GeForce GTX 1060 6GB
major: 6 minor: 1 memoryClockRate (GHz) 1.7845
pciBusID 0000:06:00.0
Total memory: 5.93GiB
Free memory: 5.84GiB
2017-05-09 15:00:35.339858: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 
2017-05-09 15:00:35.339875: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0:   Y 
2017-05-09 15:00:35.339902: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:06:00.0)
>>> print(sess.run(hello))
Hello, TensorFlow!
>>>

事前に鬼門である nvidia のドライバーと CUDA, cuDNN のインストールを済ませてあったので、すんなりと入ったようです。