TensorFlowをインストールしてみた

今さらですが、TensorFlowをインストールしてみました。

pipのインストール

$ sudo pacman -S pip

TensorFlow 1.5のインストール

1.9だとillegal instruction (core dumped)になってしまったので1.5を指定しました。

$ pip install tensorflow=1.5 --user

ちなみに--userはローカルインストールするためのオプションです。

次のようにして、インストールパスが確認できます。

$ pip show [パッケージ名]

動作確認

$ python
Python 3.6.4 (default, Jan  5 2018, 02:35:40) 
[GCC 7.2.1 20171224] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-04-19 21:12:12.121902: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
>>> print(sess.run(hello))
b'Hello, TensorFlow!'