LoginSignup
5
5

More than 5 years have passed since last update.

Centos7+anaconda2.4.1でtensorflowをインストールする

Last updated at Posted at 2016-04-16

前提

python3 -V
Python 3.5.1 :: Anaconda 2.4.1 (64-bit)

pip -V
pip 8.1.1 from /root/anaconda3/lib/python3.5/site-packages (python 3.5)

公式サイトの手順に従ってインストール

pip,virtualenv,dockerを使った方法が紹介されているが、
今回はpipでインストールする。

紹介されていたpipでのインストールコマンドではエラーが生じた。
pip3が入っていなかったので、pipで実行したが、python3.4ではなかったためか下記のようなエラーが生じた。

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl
tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl is not a supported wheel on this platform.

少し手を入れて再度インストール

ローカル環境に持ってきて名前の「cp34」→「cp35」に変更し再度インストールすると
成功したよう!
「cp34」の部分はパイソンのバージョンと関係があるようなのだが、それ以上のことはわからずじまい。。。

wget https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl
mv tensorflow-0.8.0rc0-cp34-cp34m-linux_x86_64.whl tensorflow-0.8.0rc0-cp35-cp35m-linux_x86_64.whl
pip install --upgrade tensorflow-0.8.0rc0-cp35-cp35m-linux_x86_64.whl

検証

公式サイトで紹介されているコマンドラインでの検証方法に従って、動作検証

公式サイトの結果と少しだけ異なるものの、きちんと動いてる!

cosole
$ python
>>> import tensorflow as tf
>>> hello = tf.constant("Hello, TensorFlow!")
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello, TensorFlow!' ←本当は'Hello, TensorFlow!'のみ表示される予定でした
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42

bってなんだろ・・・

5
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5