1.環境
Windows 10
Visual Studio 2017 (必須ではないかも)
Anaconda 3 (Python 3.7.4)
2.各種ソフトウェアのインストール
各パッケージのバージョンの対応は要注意
2020年1月31日現在、tensorflowのページには下記のように記載されている
https://www.tensorflow.org/install/gpu
Software requirements
The following NVIDIA® software must be installed on your system:
NVIDIA® GPU drivers —CUDA 10.1 requires 418.x or higher.
※インストールしていたのは、ver.441.87
CUDA® Toolkit —TensorFlow supports CUDA 10.1 (TensorFlow >= 2.1.0)
※https://developer.nvidia.com/cuda-toolkit-archive
CUPTI ships with the CUDA Toolkit.
※CUDA Toolkitの中に入っている
cuDNN SDK (>= 7.6)
(Optional) TensorRT 6.0 to improve latency and throughput for inference on some models.
※Visual Studio Redistribution v14.0が必要(?)で、もともとVisual Studio 2017は入れていたが、念のためVisual Studio 2015,2017,2019のランタイムをインストール
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
インストール後のPATHの設定
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include
C:\SoftTool\cuDNN\cuda\bin
※cudnn64_7.dllがあるフォルダを指す
3.Tensorflowのインストール
Pip package
See the pip install guide for available packages, systems requirements, and instructions. To pip install a TensorFlow package with GPU support, choose a stable or development package:
pip install tensorflow-gpu
※Tensorflowの“ver.1.14以下はCPUとGPUで分かれているが、1.15以降は一体”というように記載されているが、pip install tensorflowだけでは、pythonからgpuを認識できなかった。tensorflow-gpuと入力したらpythonから認識された。※上述の通りTensorflowのバージョンは2.1。
確認コマンド
参考
https://nigimitama.hatenablog.jp/entry/2018/12/24/022756