How to install Tensorflow GPU on Windows


This is going to be a tutorial on how to install tensorflow GPU on Windows OS. We will be installing tensorflow 1.5.0 along with CUDA Toolkit 9.1 and cuDNN 7.0.5. At the time of writing this blog post, the latest version of tensorflow is 1.5.0. We also did the installation guide for tensorflow 1.5.0 GPU on ubuntu 16.04 which you can find in this post here. This tutorial is for building tensorflow from source. If you want to use the official pre-built pip package instead, I recommend another post, How to install Tensorflow 1.5.0 using official pip package. If you want to install tensorflow alongside CUDA 10.0, I highly recommend our other article, How to install Tensorflow GPU with CUDA 10.0 for python on Windows.

Tensorflow is an open source software library developed and used by Google that is fairly common among students, researchers, and developers for deep learning applications such as neural networks. It has both the CPU as well as GPU version available and although the CPU version works quite well, realistically, if you are going for deep learning, you will need GPU. In order to use the GPU version of TensorFlow, you will need an NVIDIA GPU with a compute capability > 3.0.

To install tensorflow GPU on Windows is complicated especially when compared to Mac or Linux OS. Even the tensorflow’s official website states, “We don’t officially support building TensorFlow on Windows; however, you may try to build TensorFlow on Windows if you don’t mind using the highly experimental Bazel on Windows or TensorFlow CMake build.” However, here is a complete step by step working tutorial to install Tensorflow GPU on Windows (64-bit only) OS using Visual Studio 2015 Update 3 and CMake.

The steps you need to take in order to install Tensorflow GPU on Windows OS are as follows:

Step 1: Verify you have a CUDA-Capable GPU:

Before doing anything else, you need to verify that you have a CUDA-Capable GPU in order to install Tensorflow GPU. You can verify that you have a CUDA-capable GPU through the Display Adapters section in the Windows Device Manager. Here you will find the vendor name and model of your graphics card(s).

The Windows Device Manager can be opened via the following steps:

Open a run window from the Start Menu or (Win+R)


control /name Microsoft.DeviceManager

If your graphics card is from NVIDIA then go to and verify if listed in CUDA enabled GPU list.

Note down its Compute Capability. eg. GeForce 840M 5.0

Step 2: Install Visual Studio 2015 Update 3:

You will need Visual Studio 2015 in order to install tensorflow GPU on Windows. We tried installing with Visual Studio 2017 but it seems as if currently, Visual Studio 2017 is not fully supported to build tensorflow-gpu from source. So we recommend installing Visual Studio 2015 Update 3 by going to (Sign In required with Developer Account). Search for “Visual Studio Community 2015 with Update 3”. Download x64 version.

Goto Custom installation and make sure to install Visual C++ and Python Tools for Visual Studio inside Programming Language. Finish Installation.

Step 3: Download the NVIDIA CUDA Toolkit:

Go to and download Installer for Windows [your version][network]. For me, version is Windows 10. We recommend network installer.

Install it in default location with default settings. It will update your GPU driver if required.

Step 4: Reboot the system to load the NVIDIA drivers.

Step 5: Check Cuda Toolkit is set to path:

Go to run (Win + R) type cmd

The following command will check for nvcc version and insure that it is set in path environment variable.

nvcc --version

You will see something like:

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2017 NVIDIA Corporation

Built on Fri_Nov__3_21:08:12_Central_Daylight_Time_2017

Cuda compilation tools, release 9.1, V9.1.85

Step 6: Install cuDNN 7.0.5:

Goto (Membership required)

After login

Download the following:

cuDNN v7.0.5 Library for Windows [your version] for me Windows 10

Goto downloaded folder and extract cudnn-9.1-windows[your version]

Go inside extracted folder and copy all files and folder from cuda folder (eg. Bin, include, lib) and paste to “C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1”.

27 Comments on How to install Tensorflow GPU on Windows

  1. Can anyone share their working python wheel with optimization for AVX2 and cuda 9.1, cudnn 7.0.5, compute capability 6.1?
    Thank You

  2. hey I’m a complete newbie to this and i did everything you specified in the steps. but during the long 10th step my computer went to sleep. now the task manager is still showing alot of activity in the cmd, but the cmd terminal looks stuck. do i have to start the whole thing again or should i let it finish what its doing.

    • SO after 10 hours it finally ended but with 17377 warnings and 223 errors. It has used almost 9GB of space on the hard drive. Can you please tell me how to fix this. I followed your guide exactly. I had a previously installed tensorflow version and it stopped working and that’s why i used this guide to reinstall it. I’m wondering if the old one is interfering with this install. if there is way to fix this how should i clean the current install?

      • You can follow the tutorial “how to install tensorflow using official pip package ” there is the process to uninstall cuda 9.1 and install cuda 9.0. So that you can easily install tensorflow. Currently this article is tested on tf 1.5.0 and not tested on tf 1.7.0.

  3. Hi, I think it worked for me, but for some reason tensorflow takes an awful long time before the calculation actually starts.
    I didn’t compile myself, but used the wheel you linked to at the bottom. I used “tensorflow_gpu-1.5.0-cp36-cp36m-win_amd64.whl”.

    When I use this test code:

    import tensorflow as tf
    with tf.device(‘/gpu:0′):
    a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name=’a’)
    b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name=’b’)
    c = tf.matmul(a, b)
    with tf.Session() as sess:
    print (

    I get:

    (keras) c:\python_code\UDEMY\DeepLearningGrundlagen\5.nn_in_tf>C:/anaconda/envs/keras/python.exe c:/python_code/test/
    2018-04-10 16:38:23.009256: I C:\tensorflow-1.5.0\tensorflow\core\common_runtime\gpu\] Found device 0 with properties:
    name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335
    pciBusID: 0000:01:00.0
    totalMemory: 8.00GiB freeMemory: 6.60GiB
    2018-04-10 16:38:23.017566: I C:\tensorflow-1.5.0\tensorflow\core\common_runtime\gpu\] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
    [[22. 28.]
    [49. 64.]]

    So I think CUDA is working, right? But it takes like 5 minutes until the numbers show up (2 last lines). This isn’t normal right? How can i fix this?

  4. How long should step 9 take? I’ve got “– Configuring done” but it’s been stuck there for an hour or two. And watching my task manager, it doesn’t seem to be doing anything intensive that would take a long time.

    Think I should stop the command and restart? What could’ve gone wrong?

    • Tried to cancel it with CTRL+C, and it immediately printed “Generating done” and seems to have worked. Guess I’ll move on, then. Never mind to my earlier comment.

      • Good luck for step 10. It may take more than 5 hours. I will soon update this tutorial for latest tensorflow. Which TF you are building ?

        • Building it for Nvidia GPU, version 1.5.1. Took about 5 and a half hours to build (with a massive number of warnings but no errors), then installed quickly.

          When verifying, it prints out “b’Hello, TensorFlow!'” with a “b” in front, not sure why… I’ll test it on some neural networks soon though.

          • Just tried it on a CNN we were learning in a workshop, and worked beautifully. Thanks so much for this guide!

  5. Can’t run this command:
    cmake -G “Visual Studio 14 2015 Win64” -T host=x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=c:/swigwin-3.0.12/swig.exe -Dtensorflow_ENABLE_GPU=ON -Dtensorflow_CUDA_VERSION=9.1 -Dtensorflow_CUDNN_VERSION=7 -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX2 ..

    Error : C:\ does not contain CMakeList.txt

      • When I run the above I get this output:

        — Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED – Failed
        — Performing Test COMPILER_OPT_WIN_CPU_SIMD_SUPPORTED – Success
        — Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1 (found suitable version “9.1”, minimum required is “9.1”)
        — Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
        CMake Error at CMakeLists.txt:397 (message):
        CMake was unable to find a python interpreter.

        What do I need to do to find a python interpreter?

        • Python should be in path also make sure it is 64 bit. You can also use separate python by activating virtualenv and then configure.

          • When i try to Configure Tensorflow from source using CMake, I get the following message:

            c:\tensorflow\tensorflow\contrib\cmake\build>cmake -G “Visual Studio 14 2015 Win64” -T host=x64 -DCMAKE_BUILD_TYPE=Release
            CMake Error: The source directory “C:/tensorflow/tensorflow/contrib/cmake/build” does not appear to contain CMakeLists.txt.
            Specify –help for usage, or press the help button on the CMake GUI.

            When I look in the build file I see no CMakeLists.txt file, what is wrong here?

  6. Hi Arun, thanks for the extremely detailed instructions for installing tensorflow gpu. I have followed most of your instructions, but made some sequence mistakes due to which I had to rebuild the whl file. I got 13,762 warnings, but 0 errors, so assumed that this would work.

    My challenge is that when I attempted to execute the pip install command, I got a series of “requirement already satisfied” responses. I assumed that this meant that tensorflow was already installed, but a pip uninstall confirmed that tensorflow was not installed (“Cannot uninstall requirement tensorflow, not installed”).

    when I went into python and attempted to import tensorflow, I found that python was still looking for cudart_90.dll, not v9.1 which I had installed. Here is the detailed error message:

    ImportError: Could not find ‘cudart64_90.dll’. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 9.0 from this URL:

    I’m trying to figure out my options at this point:

    1. Uninstall everything, start again: how far back do I go?

    2. Do I simply rebuild? If so, what changes do I need to make before rebuilding?

    3. Attempt to resolve the “requirement already satisfied” error: assuming that if I can fix this, I’ll be able to execute pip install tensorflow

    4. Attempt to resolve mis-direction to cudart_90.dll instead of …91.dll: not sure if this will lead to a subsequent error downstream, or fix everything?

    Please advise and suggest. My config/ install is as follows:

    CUDA v9.1
    GPU: Nvidia 1060
    AVX2 works
    Windows 10
    VS 2015 Update 3, custom install as you suggested
    cudart_91.dll and cudnn 7.0.5 installed as suggested
    My whl had a cp36 name instead of cp35, and I made the edit accordingly.


    • What is the full name of whl file you built? Use clean virtual environment with correct python version. Install that whl using pip3 install [whl file path]. No need to rebuild.

  7. Thank you for your tutorial.

    Following your instruction ‘nvcc -version’, I got this error message. Could you please help me to resolve it.

    nvcc fatal : Unknown option ‘version’

    • I think double dash is required. But you can continue because that step is to check if nvcc is set to path and it is done correctly.

  8. Thank you, Arun for such detailed guide!

    i’ve got error:

    — Performing Test COMPILER_OPT_WIN_CPU_SIMD_SUPPORTED – Success
    — Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1 (found suitable version “9.1”, minimum required is “9.1”)
    — Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version “3.6.3”)
    — Found PythonLibs: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36.lib (found version “3.6.3”)
    CMake Error at tf_python.cmake:51 (message):
    Cannot get NumPy include directory: Is NumPy installed?
    Call Stack (most recent call first):
    CMakeLists.txt:422 (include)

    — Configuring incomplete, errors occurred!

    Looks like it’s a Numpy trouble.
    I’ve got Numpy 1.14.0:

    (base) C:\WINDOWS\system32>conda install numpy
    Solving environment: done

    # All requested packages already installed.

    any suggestions pls?

    • Here it is using python from C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe. Activate conda environment as written in step 9 (optional) or directly install numpy without active environment using pip. I recommend to use prebuilt whl unless if you really want to build it.

  9. Thank you for the tutorial! Finally, I can enjoy tensorflow-gpu!
    I didn’t manage the whole installation from this tutorial because encountered an error:
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5):
    error MSB6006: “cmd.exe” exited with code 1. [C:\tensorflow\tensorflow\contrib\cmake\build\

    But successfully used the alternative method: I made it work with CUDA 9.1 by simply copying and renaming particular files in its folder, as it was elaborated in the comment of hartagga 2018-01-29 AT 16:09

  10. Hi. Got an error saying device_function.h not found in cuda/ directory. Now i moved contents from C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include into C:\tensorflow\third_party\gpus\cuda\include. Rebuilding once again

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.