Building a TensorFlow environment that uses GPU on Windows 10
Building a TensorFlow environment that uses GPU on Windows
I built an environment to run TensorFlow with Python using Anaconda and spyder
Basically, I refer to the following
[Intelligent Curiosity How to Use tensorflow-gpu on Windows 10](https://intellectual-curiosity.tokyo/2019/06/17/windows-10%E3%81%A7tensorflow-gpu%E3%82%92% E4% BD% BF% E3% 81% 86% E6% 96% B9% E6% B3% 95 /)
PC environment
- Windows10(64bit)
- GeForce GTX1070
What to use
- Anaconda(Python3.6)
- CUDA Toolkit 10.0
- cuDNN v7.6.0
- Tensorflow-gpu 1.13.1
- VisualStudio2019※
- I installed it because it is used in Reference page, but I have not used it for development.
Precautions when setting the environment
Depending on the version of each package, it may not recognize the GPU.
Be sure to check the version to install from this table
Installation of Anaconda
- Anaconda Download Page
Download the Python 3.7 Windows installer from
- Start the installer, agree to the terms and specify the installation destination, and install
Reference: Install Pythonjapan Windows version
Install Cuda Toolkit
This page is used as a reference.
You need to install Microsoft Visual Studio in advance.
- Download the Toolkit from the CUDA installation page (https://developer.nvidia.com/cuda-toolkit-archive)
--Click CUDA Toolkit 10.0 and select [Windows]-[x86-64]-[10]
(The last version is the version of Windows)
- "Be sure to check the version you are installing on here"
- Install from the downloaded installer
--Agree to the terms and select the installation destination
--Choose a custom option
--Install according to the installer (I think there is no problem with the basic "Next")
- Check environment variables
--Control Panel-> System and Security-> System-> Advanced System Settings-Select Environment Variables
--Make sure the system environment variables are:
CUDA_PATH : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
--Also check that the Path value of the user environment variable has the following:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\lib64
- Check where nvcc passes at the command prompt
If the installation is successful, the path of the cuda exe file will be displayed.
cuDNN installation
- File download
-Go to Download Page
--Registration as you will be required to register as a member of Nvidia Developer
--Go to the download page again and download the version you want to install
- Download file adaptation
--The Zip file will be downloaded, so unzip it with the extraction software.
--Since the same folder exists in the folder where CUDA is installed (C: \ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v10.0), copy the downloaded folder to CUDA.
--Add the following to your system environment variables
CUDNN_PATH : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
Install tensorflow-gpu
This page is used as a reference.
It is recommended to build a virtual environment because tensorflow using cpu and tensorflow-gpu conflict and are compatible depending on the version.
- Create a virtual environment for Anaconda
--Open anacondaPrompt and build a virtual environment with commands
> conda create -n [Environment name] python=3.6 anaconda
> activate [Environment name]
- Install tensorflow-gpu in the created virtual environment
Execute the following command
-[version] enter the version you want to install
> pip install tensorflow-gpu==[version]
- Test
Execute the following command to start spyder
> spyder
Do the following on Spyder
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
Success if device_type: "GPU" is displayed at the bottom of the output
reference
Intellectual Curiosity How to use tensorflow-gpu on Windows 10: https://intellectual-curiosity.tokyo/2019/06/17/windows-10%E3%81%A7tensorflow-gpu%E3%82%92%E4% BD% BF% E3% 81% 86% E6% 96% B9% E6% B3% 95 /
Pythonjapan Windows version installation: https://www.python.jp/install/anaconda/windows/install.html
Installing NVIDIA CUDA Toolkit 10.1 (on Windows): https://www.kkaneko.jp/tools/win/cuda.html
GPU version TensorFlow environment construction (Windows 10): http://tecsingularity.com/cuda/tensorflowenv/