LoginSignup
11
13

More than 5 years have passed since last update.

fedora23 に機械学習ライブラリ TensorFlow をインストールする

Posted at

fedora23 に Python の機械学習ライブラリ TensorFlow をインストールします。
TensorFlow ってなんだろ - Qiita

必要なもの

Python のインストール

によると、現時点では Python2.7 が必要です。

fedora23 にデフォルトで入っているのは Python3 のみのため、Python2 系をインストールします。

numpy のビルドに必要なので、 python-devel を同時にインストールします。

sudo dnf install python python-devel

2系と3系の共存が可能です。

$ python --version
Python 2.7.10
$ python3 --version
Python 3.4.3

specs ファイルの追加

以下のエラーが出る場合は、 rpm-build が必要です。

gcc: エラー: /usr/lib/rpm/redhat/redhat-hardened-cc1: そのようなファイルやディレクトリはありません

rpm-build をインストールします。

sudo dnf install rpm-build

参考: "mysql_config --cflags" does not work on fedora 21 - Ask Fedora: Community Knowledge Base and Support Forum

これは specs ファイルと言い、ビルド時の動作を決定するファイルらしいです。
参考: 猫科研究所 - GCCのspecsとは

インストール

ここではCPUのみを演算に使うバージョンをインストールします。

$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl

GPUを利用する場合は、CUDAのSDKが必要です。

動作確認

$ python
Python 2.7.10 (default, Sep  8 2015, 17:20:17) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 1
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 1
>>> print sess.run(hello)
Hello, TensorFlow!
11
13
0

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
11
13