Document Source reprint: http://blog.csdn.net/u010099080/article/details/53418159
Http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html
Pre-Installation Preparation
There are two versions of TensorFlow: CPU version and GPU version. The GPU version requires CUDA and CuDNN support, and the CPU version is not required. If you want to install the GPU version, make sure your video card supports CUDA first. I installed the GPU version, using the PIP installation, so in the case of GPU installation, the CPU version simply does not need to install CUDA and CuDNN.
- Check here for your graphics card support CUDA.
- Make sure your Python version is 3.5 64-bit and above. (TensorFlow support for Python 3.6 from 1.2, previously not supported by the official)
- Make sure you have a stable network connection.
- Make sure your pip version is >= 8.1. Use
pip -V
pip
the upgrade to view the current version python -m pip install -U pip
pip
.
- Make sure you have VS2015 or 2013 or 2010 installed. This article is not required, delete.
In addition, it is recommended to install Anaconda, because this integrates many of the necessary libraries for scientific computing, can avoid many dependencies, installation tutorials can refer to here.
The above conditions, then congratulations you can start to download Cuda and CuDNN installation package, note that the version number is Cuda 8.0 and CuDNN 5.1 (due to different versions of TensorFlow, 5.1 is no longer applicable to the new version, here please combine the installation CuDNN instructions), which is officially recommended by Google. can go to their official website to download, I have been downloaded to play into a compressed package put to the Baidu cloud, we can download from here, password 5aoc.
Installing TensorFlow
As Google's people have already made TensorFlow a PIP installation package, it is now possible to install TensorFlow in the same way as the normal installation package, which is to go to the command line and execute the following simple statement:
# GPU版本pip3 install --upgrade tensorflow-gpu# CPU版本pip3 install --upgrade tensorflow
Then the installation begins, depending on the speed of the network.
After installing the net you try to tell in Python that import tensorflow
you did not find CUDA and CuDNN, so the next step is to install these two items.
Installing Cuda 8.0
Download and install Cuda Toolkit
Toolkit version 8.0 or later:https://developer.nvidia.com/cuda-downloads
Sample installation directory:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
This is also very simple, download the compression package I gave above, extract, get two files, the exe file is CUDA8 installation program, directly double-click to execute, just like other software installed normal, the installation process screen may blink, it does not matter, and installation time is a bit long.
After installation, the system variables will be added to you automatically, this is not a tube.
Test the installation success, command line input nvcc -V
, see the version information indicates that the installation was successful.
Installing CUDNN
Google released the TensorFlow 1.3 around August 17, 2017, which no longer supports CuDNN 5, started supporting CuDNN 6, and is expected to support TensorFlow 7 in CuDNN 1.4, so that when When you use PIP to install the latest version, please use CuDNN 6 instead of the 5.1 I provided, otherwise there will be problems with issues #2.
Release notes for CuDNN in TensorFlow 1.3:
All of our prebuilt binaries has been built with CuDNN 6. We anticipate releasing TensorFlow 1.4 with CuDNN 7.
Release notes for CuDNN in TensorFlow 1.2:
TensorFlow 1.2 May is the last time we build with CuDNN 5.1. Starting with TensorFlow 1.3, we'll try to build all our prebuilt binaries with CuDNN 6.0. While we'll try to keep our source code compatible with CuDNN 5.1, it'll be the best effort.
Download and install the applicable
in Windows 10 CuDNN CuDNN version 6.1 library: HTTPS://developer.nvidia.com/cudnn
you will need to register with nvidia to download these files. Now extract the Cudnn file into your toolkit directory
Environment variables
Make sure that the cuda_home is set to an environment variable after the CUDA toolkit is installed. If not, then you need to add it manually.
Is the same as the PATH variable:
Installing Anaconda
We will install Anaconda because it can help us easily manage a separate environment for a specific Python release without affecting the version of Python that is installed on the system.
Download and install
Anaconda
Create a Conda environment
Create a new environment with the name Tensorflow-gpu and Python version 3.5.2
conda create -n tensorflow-gpu python=3.5.2
Activating the Environmentactivate tensorflow-gpu
Installing TensorFlow
pip install
Https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/gpu/tensorflow_gpu-1.3.0rc0-cp35-cp35m-win_amd64.whl
Here I am in Tsinghua Source network installed TENSORFLOW-GPU version 1.3, the targeted version of the installation.
completed. you have successfully installed a tensorflow with a GPU on your Windows machine.
Now let's test whether it uses the GPU ...
Activating the environment we created
activate tensorflow-gpu
Testing the GPU
Enter the Python shell
python
import tensorflow as tf
Now run this command and check to see if it recognizes your GPU.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
Issues#1
Cannot remove entries from nonexistent file
If a similar error occurs when installing TensorFlow Cannot remove entries from nonexistent file c:\users\li\anaconda3\lib\site-packages\easy-install.pth
, then refer to cannot remove entries from nonexistent #622 and OSX 10.11 installation issues #135 , there are a lot of solutions, I'm here to introduce a method: pip3 install --upgrade tensorflow-gpu
before the first execution pip install --upgrade --ignore-installed setuptools
.
#2
ImportError: DLL load failed: 找不到指定的模块。
And
ImportError: No module named ‘_pywrap_tensorflow_internal‘
If import tensorflow
these two problems occur at the same time, it is likely that your cuda and CUDNN versions have problems, such as your Cuda version 8.0.60
, and the correct one is to reinstall the 8.0.44
correct version (provided in the article). Reference on Windows, running "Import TensorFlow" generates No module named "_pywrap_tensorflow" error. Thank @qq_27690673 for the information provided.
#3
ImportError: No module named ‘tensorflow.python.pywrap_tensorflow_internal‘
If import tensorflow
This problem occurs at the time, then you may have entered the Python interpreter in the TensorFlow source directory. Leave the directory and re-enter the Python interpreter.
TENSORFLOW-GPU installation on WINDOWS10 (Anaconda)