LoginSignup
5
5

More than 5 years have passed since last update.

Windows10-CUDA9.2でTensorflowの学習環境構築

Posted at

環境

  • Windows10
  • GTX1060
  • Intel Corei7-7700HQ 64bit
  • python 3.6.5 Anaconda

VisualStudio2015のダウンロード

https://my.visualstudio.com/Downloads?q=Visual%20Studio%202015%20with%20Update%203

※マイクロソフトのIDとパスワード(プロファイル)が必要

※Visual C++とWindows10 SDK

microsoft2015.png

VisualStudio2015で後から機能追加する方法

プログラムの追加と削除からVisualStudio2015with~を選択して変更。

  • Visual C++
  • Python tools
  • ユニバーサル Windows アプリ開発ツール

の3つにチェックを入れる。
visualstudio2015.png

確認

「Microsoft Visual Studio の C/C++ をコマンドで使ってみる」の部分で確認できる。
VisualStudio2017と機能がかぶっていると上手くインストールできないので、2017側を変更する必要あり。

CUDA9.2インストール

cuDNN

CUDA9.2用cuDNNをインストール

cuDNN.png

Tensorflow

Cuda9.2にした場合、Tensorflowは公式サポートしていないので、上記からダウンロードして
pip install *.whlを実行する。

自分の環境の場合は、
pip install tensorflow_gpu-1.9.0-cp36-cp36m-win_amd64.whl
を実行。

確認

>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-08-22 17:02:51.383906: I c:\users\user\source\repos\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2018-08-22 17:02:51.665631: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties:
name: GeForce GTX 1060 major: 6 minor: 1 memoryClockRate(GHz): 1.6705
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 4.97GiB
2018-08-22 17:02:51.673872: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0
2018-08-22 17:05:16.937817: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-08-22 17:05:30.298138: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958]      0
2018-08-22 17:05:30.302202: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   N
2018-08-22 17:05:30.307152: I c:\users\user\source\repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4734 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1)
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

jupyter notebookでも確認

from tensorflow.python.client import device_lib
device_lib.list_local_devices()

出力

[name: "/device:CPU:0"
 device_type: "CPU"
 memory_limit: 268435456
 locality {
 }
 incarnation: 7345176785926211181, name: "/device:GPU:0"
 device_type: "GPU"
 memory_limit: 4964889395
 locality {
   bus_id: 1
   links {
   }
 }
 incarnation: 8947061546033152560
 physical_device_desc: "device: 0, name: GeForce GTX 1060, pci bus id: 0000:01:00.0, compute capability: 6.1"]

読み込んでいるのを確認。

5
5
1

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