LoginSignup
5
2

More than 5 years have passed since last update.

tensorflow 1.1.0の手動ビルドを試す(CPU拡張命令+XLAでどの程度高速化するか)

Posted at

tensorflow 1.1.0を試してみた

tensorflowに触れる機会があったので、ソースからのビルドを試してみた
参考にしたページ: http://blog.amedama.jp/entry/2017/03/08/223308
このページの手法ほぼそのままです

環境

  • MacBookPro 13inch 2015モデル
  • Core i7
  • tensorflow 1.1.0
  • python 3.6.1

1.1.0リリースノートで気になったこと

  • TensorFlow 1.1.0 will be the last time we release a binary with Mac GPU support. Going forward, we will stop testing on Mac GPU systems. We continue to welcome patches that maintain Mac GPU support, and we will try to keep the Mac GPU build working.

MacのGPUサポートしたバイナリ出すのこれが最期だって。

ビルド時にやったこと(参考ページとの差分)

https://github.com/tensorflow/tensorflow/releases

から1.1.0のtar.gzをダウンロード

configure

  • 1.1.0ではconfig=optで追加するオプションをconfigureで聞いてきます
    デフォルトのmarch=nativeでいいはず
    XLA just-in-time compiler も有効化してみる

XLAはexperimental扱いです
ビルドは30分ほどで完了

計測

march=native+XLA版

$ time python3 mnist_cnn.py
real 23m23.336s
user 63m39.019s
sys 13m32.681s

pipで入るバイナリ

$ time python3 mnist_cnn.py
real 34m48.798s
user 110m22.508s
sys 11m11.853s

結論

一回しか測ってないので正確ではありませんが、処理時間が2/3ほどになりました
CPUでいろいろ試す場合は自分でビルドする価値はあるかもです

おまけ:デスクトップで試してみた

  • Ubuntu 16.04
  • Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
  • NVIDIA Geforce GTX 1050
  • CUDA 8.0
  • cudnn 5.1
  • python 3.5.2
  • pipでtensorflow-1.1.0のgpu版を導入

$ time python3 mnist_cnn.py
real 2m21.907s
user 1m57.300s
sys 0m13.444s

1万円ちょいで買える安GPUでも10倍速かったです

5
2
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
5
2