LoginSignup
9
8

More than 5 years have passed since last update.

WindowsにTensorflowを入れてみる(成功編)

Last updated at Posted at 2018-07-06

始めに

昨日トライしてダメだったのの続きです。
最終的にうまく行ったら他の環境で精査の上、見やすい記事にする。
AnacondaやPython等は一度アンインストールしました。

TensorFlowインストール

参照

「TensorFlowのオリジナルのインストールページ」https://www.tensorflow.org/install/install_windows

未確認情報

Visual C 2015再配布のライブラリが無いとダメだという情報もある。

ここまではぶつからないだろうと、下記OKという事でパス

    CUDA Toolkit 9.0. For details, see NVIDIA's documentation Ensure that you append the relevant Cuda pathnames to the %PATH% environment variable as described in the NVIDIA documentation.
    The NVIDIA drivers associated with CUDA Toolkit 9.0.
    cuDNN v7.0. For details, see NVIDIA's documentation. Note that cuDNN is typically installed in a different location from the other CUDA DLLs. Ensure that you add the directory where you installed the cuDNN DLL to your %PATH% environment variable.
    GPU card with CUDA Compute Capability 3.0 or higher for building from source and 3.5 or higher for our binaries. See NVIDIA documentation for a list of supported GPU cards.

実はダメでした。バージョンがCUDA9.2とcuDNN7.1でもいけるだろと思ったらCUDA9.0とcuDNN7.0でないとダメらしい…

Python3.6.6インストール

素朴な疑問として、3.7.0でも動くんだろうか?

https://www.python.org/downloads/release/python-366/
から
「Windows x86-64 executable installer」
クリックして下記を落とします。

python-3.6.6-amd64.exe

昨日失敗した、コマンドプロンプトでpipで入れる。

ただしこれやるなら先にpipのアップグレードでしょうな。

>> pip install --upgrade pip

またダメだというので

>> python.exe -m pip install --upgrade pip

最新らしいです。

でわ。

pip install --upgrade tensorflow-gpu

…アクセス禁止らしい。

では管理者モードでコマンドプロンプト起動後。

pip install --upgrade tensorflow-gpu

…ありゃ。はいっちゃったよ。

ただし、PATHに下記を追加する。

C:\program files\python36\Scripts

では、Validate your installation

>> $ python
>>> import tensorflow as tf

ImportError: Could not find 'cudart64_90.dll'…

…………… (T_T)

もしかして、CUDA9.2じゃダメなのか?
という仮説の元、CUDA9.0を落としに掛かる。

CUDA / cuDNN再インストール

「CUDA Toolkit 9.2 Download」
https://developer.nvidia.com/cuda-downloads
から
「Windows」
まで選んだ上で…ページ中段くらいの
「Legacy Releases」
を叩く。

CUDA Toolkit 9.0に飛びます。

4つ落として順に入れる

cuda_9.0.176_win10.exe
cuda_9.0.176.1_windows.exe
cuda_9.0.176.2_windows.exe
cuda_9.0.176.3_windows.exe

もう一度Tensorflow動作確認

Validate your installation

>> $ python
>>> import tensorflow as tf

ダメでした。

cuDNNもバージョンを揃えないとダメか?

前例があるので、cuDNNも7.1でなくて7.0系を試す事にする。

ログインして、「Software License Agreement」にチェックすると選択肢が現れるが、その中でも枠外に出てくる「Archived cuDNN Releases」を選択。

「Download cuDNN v7.0.5 [Dec5, 2017], for CCUDA 9.0」
から
「cuDNN v7.0.5 Library for Windows10」選んで下記を落としてくる。

cudnn-9.0-windows10-x64-7.zip

展開すると「cuda」フォルダ下に、「bin」「include」「lib/x64」フォルダが現れるので、中のファイル(dll)を

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\

の該当するフォルダにコピーする。

今度こそ。最後まで行きました。

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

余裕があったら、修正加筆して別に掲載します。

9
8
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
9
8