1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

今更ながらTensorflow-GPUの速さに感動したのでメモ

Last updated at Posted at 2017-12-16

きっかけ

そういえば、我が家のWindowsマシン(2010年購入:何とかまだ現役)はNVIDIAのグラボを積んでいたという事を思い出したので、Tensorflow-GPUを今更ながら試してみようと思った。
ディープラーニングが目的というよりは、並列計算の速さを試すという観点。

PCスペック

OS: Windows7 Home Edition
CPU: インテルCORE i7-860(初代のi7)
GPU: GeForce GTX 650
メモリ: 8GB DDR3

やったこと

tensorflowのインストール

pythonはChocolatey経由でインストール済み。
Tensorflowをインストールする。

> pip install tensorflow
> pip install tensorflow-gpu

バージョン等

python 3.6.3
tensorflow 1.4.0
tensorflow-gpu 1.4.0
matplotlib 2.1.1

CPU vs GPUの比較をしてるサイトのソースをコピペ

Introduction to TensorFlow — CPU vs GPU

CUDA関連のソフトをインストール

何にも考えずに、実行しようとしたら下記を入れろとTensorflowに怒られたので、インストール。

CUDA Toolkit 8.0
cuDNN v6.0 Library for Windows 10
※メンバ登録(無料)が必要

記事のオリジナルの結果(縦軸は秒)

Introduction to TensorFlow — CPU vs GPU

我が家の環境での実行結果(縦軸は秒)

上記サイトのソースをコピペしてそのまま実行(行列サイズを50ずつ増やしながら、1.5秒以上演算にかかるところでストップ)

cpu_vs_gpu.png

少し条件を変えた実行(行列サイズを50ずつ増やしながら、5秒以上演算にかかるところでストップ)

cpu_vs_gpu2.png

GPUのみで実行

gpu_only1.png

5000×5000の行列演算が1.5秒で終わる。

最初の一回目の演算が必ず遅くなるのはなんだろう?と思って、ipython上で連続実行してみたら2回目は以下のような結果になった。キャッシュが使われて早くなるのだろうか?
(引用元のサイトによれば”The initial GPU delay at the first iteration is perhaps due to TensorFlow setting starting up stuff.”とのこと)

gpu_only2.png

ちなみに10000x10000の行列演算をしたら、GPUメモリをオーバフローしたのかエラーで止まってしまった。GPU使ってるからディスプレイがブラックアウトして心臓に悪い。

まとめ

使い古しの骨董GPUだけど、並列計算に全然使えるレベルということが分かった。
ディープラーニングのためというよりは、普通に行列演算に使って遊ぼうと考え中。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?