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.

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”.

Step 7: Install Dependencies

git (required)

If you have already git then skip this else do this.

go to download git and install with all default settings.

CMake (required)

Goto and download Windows win64-x64 Installer.

Direct link

Install it but make sure to check Add Cmake to system path for all users.

swig (required)

goto and download swigwin.

Direct link

Extract it to C:\

Step 8: Verify if your CPU support AVX/ AVX2:

AVX/AVX2 optimization make tensorflow perform faster.

You can verify for AVX/ AVX2 support for your CPU by using Coreinfo tool.

Goto to get it.

Direct link

Extract it to C:\

Goto run (Win+R) and type cmd

Run following command:


Look for AVX

AVX             *       Supports AVX intruction extensions

If you got * then it supports AVX.

Step 9: Configure Tensorflow from source using CMake:

Start the process of building TensorFlow by downloading latest tensorflow 1.5.0

Goto run (Win+R) and copy paste following:

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt.lnk"
cd c:\
git clone
cd tensorflow
git checkout r1.5
cd tensorflow\contrib\cmake
mkdir build
cd build


Activate your virtual environment eg. Virtualenv, conda, anaconda with python version 3.5. This makes CMake detect python automatically with python related to your virtual environment.

Install numpy (required):

pip install --upgrade numpy
pip install --upgrade wheel

If AVX is supported by your CPU then do following:

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 ..

Else do following:

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 ..

You can see:

-- Configuring done
-- Generating done
-- Build files have been written to: C:/tensorflow/tensorflow/contrib/cmake/build

Goto “C:\tensorflow\third_party\gpus\cuda\ ” and open “cuda_config.h” with any editor or notepad.

Edit this line with your CUDA capability noted in step 1:

 #define TF_CUDA_CAPABILITIES CudaVersion("3.0"),CudaVersion("3.5"),CudaVersion("5.2")

For my GPU, CUDA capability is 5.0

#define TF_CUDA_CAPABILITIES CudaVersion("5.0")

Verify following files with numbers as specified below:

#define TF_CUDA_VERSION "64_91"
#define TF_CUDNN_VERSION "64_7"

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\cudart64_91.dll"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\cudnn64_7.dll"

If all good then we are ready to build Tensorflow.

Step 10: Build Tensorflow using MSbuild

Copy this file (required):

"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include\crt\math_functions.hpp" to "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include\"


Disable real-time protection of Windows Defender or any other antivirus. We found that doing this dramatically decreases build time by a few hours.

Build using MSbuild to create whl file (pip package) using the following command:

MSBuild /p:Configuration=Release /verbosity:detailed tf_python_build_pip_package.vcxproj

It will take 4 -5 hours if antivirus disabled.

Step 11: Install Tensorflow GPU on Windows

Finally… Activate virtual environment here where you want to install tensorflow.

To install tensorflow gpu on windows with pip:

pip install "C:\tensorflow\tensorflow\contrib\cmake\build\tf_python\dist\tensorflow_gpu-1.5.0-cp35-cp35m-win_amd64.whl"

note- correct whl filename if not found.

Step 12: Verify Tensorflow installation

Run in terminal


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

If the system outputs the following, then you are ready to begin writing TensorFlow programs:

Hello, TensorFlow!

Success! You have now successfully installed tensorflow GPU on windows machine.

Since it is experimental as stated on the official website, comment below if any errors occurred.

If you can’t make it, then go to  How to install Tensorflow 1.5.0 using official pip package. for alternative.

For prebuilt wheel with optimization for AVX2 and cuda 9.1, cudnn 7.0.5, compute capability 5.0 go to this link .

Do let us know in the comments below if it worked for you. Or if you got any errors. Cheers!


93 Comments on How to install Tensorflow GPU on Windows

  1. Thank you for your tutorial,

    Following your instruction, I got this error message after 7:30 hours while the code was trying to build tensorflow using MSbuild. Could you please help me to resolve it

    oj” (default target) (1) ->
    j” (default target) (3) ->
    .vcxproj” (default target) (4) ->
    “C:\tensorflow\tensorflow\contrib\cmake\build\tf_c.vcxproj” (default target) (5
    ) ->
    “C:\tensorflow\tensorflow\contrib\cmake\build\tf_cc_framework.vcxproj” (default
    target) (6) ->
    “C:\tensorflow\tensorflow\contrib\cmake\build\tf_core_framework.vcxproj” (defau
    lt target) (7) ->
    (CustomBuild target) ->
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.ta
    rgets(171,5): error MSB6006: “cmd.exe” exited with code 3. [C:\tensorflow\tenso

    • Do you have latest cmake x64? If no then install it as given in step 6 and reboot your pc. If you have the latest cmake x64 than reboot pc.

      Then Goto run (Win+R) and copy paste following:

      “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\Windows Desktop Command Prompts\VS2015 x64 Native Tools Command Prompt.lnk”

      cd c:\tensorflow\tensorflow\contrib\cmake\build
      MSBuild /p:Configuration=Release /verbosity:detailed tf_python_build_pip_package.vcxproj

      Hope this time it can build it successfully but just in case if you got error again then this time we will have detailed info. Please comment that info.

      • Thanks for your reply Arun! Actually, I installed tensorflow using the alternative method provided at the very end of the tutorial and it was successful. Could you please let me know how these two methods are compared in terms of performance?

        • I am glad to hear successful installation of tensorflow. Actually build on machine fully optimize tensorflow with optimum performance and with compatibility with installed dependencies and libraries. Tensorflow found in as a whl package are built as generic so that it will work for all system.

      • Following your instruction, I got this error message after several times of tries while the code was trying to build tensorflow using MSbuild. Could you please help me to resolve it:
        “c:\tensorflow\tensorflow\contrib\cmake\build\tf_python_build_pip_package.vcxproj”(default target) (1) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal.vcxproj”(default target) (3) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal_static.vcxproj”(default target) (4) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\tf_c.vcxproj”(default target) (5) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\tf_cc_framework.vcxproj”(default target) (6) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\tf_core_framework.vcxproj”(default target) (7) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\proto_text.vcxproj”(default target) (8) ->
        “C:\tensorflow\tensorflow\contrib\cmake\build\grpc.vcxproj”(default target) (9) ->
        (CustomBuild target) ->
        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\grpc.vcxproj]
        Is it related to I’m in China?

        • Build with “MSBuild /p:Configuration=Release /verbosity:detailed tf_python_build_pip_package.vcxproj” and send me the log link. Does cmake, git set to path? Does AVX supported? Configure cmake without AVX and try to build with verbosity.

          • Thank you for the reply,here is the log: ,and I check the path,make sure that the C:\Program Files\Git\cmd and C:\Program Files\CMake\bin is already set to path.And AVX is supported,so I follow your instruction and do this:

            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 ..

            and I see this successfully:

            — Configuring done
            — Generating done
            — Build files have been written to: C:/tensorflow/tensorflow/contrib/cmake/build

            so do I need to configure cmake without AVX and try to build with verbosity?and how?

            thanks again!

      • Hi, when I ran:

        cmake -G “Visual Studio 14 2015 Win64” -T host=x64 -DCMAKE_BUILD_TYPE=Release -DSWIG_EXECUTABLE=c:/swigwin-3.0.12/swig.ex
        e -Dtensorflow_ENABLE_GPU=ON -Dtensorflow_CUDA_VERSION=8.0 -Dtensorflow_CUDNN_VERSION=6 -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX2 ..

        I got this error:

        — The C compiler identification is unknown
        — The CXX compiler identification is unknown
        CMake Error at CMakeLists.txt:5 (project):
        No CMAKE_C_COMPILER could be found.

        CMake Error at CMakeLists.txt:5 (project):
        No CMAKE_CXX_COMPILER could be found.

        — Configuring incomplete, errors occurred!
        See also “C:/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeOutput.log”.
        See also “C:/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeError.log”.

        I got this error even though I installed Visual Studio and Cmake as mentioned above. I have also put Cmake in the %PATH% list. The only difference is that I want to use CUDA=8.0 and CuDNN=6. I have attached the log, error and the build files here:

        • I ran into the same issue… If you just downloaded/installed VS Community 2015 with Update 3 (Step 2) and then proceeded without opening VS, you would definitely run into the “No CMAKE_CXX_COMPILER” issue… Reason being VSC 2015 does not download C++ dependencies when installed… The solution is to open VSC 2015 after installation completes, create a new C++ Project and there it will prompt you to install additional files. Once you do that it works like a charm!

          • Thanks a lot for this great Tutorial Arun! My first ever build from the source and it worked perfect. Just a few issues I ran into in Step 2:
            a. One has to Install Windows 8.1 SDK from ‘Individual Components’ section when installing VSC 2015. Failure to do so will result in an error message stating missing Win 8.1 SDK or something during step 9.
            b. Once installation completes, open VSC 2015 and create a C++ project – this will prompt you to download additional C++ dependencies which are not installed during the actual VSC 2015 Update 3 installation. Failure to do so will result in “No CMAKE_CXX_COMPILER” error message.

            The build took me Time Elapsed 18:07:53.69, with 20452 Warning(s), 0 Error(s).
            Thanks for the great tutorial Arun!!

    • Goto and signin with microsoft account. Then goto downloads tab and search for “Visual Studio Community 2015 with Update 3” in search bar. Then download from there as x64 version is selected by default. Reply if any other query.

          • 1. There is no `VS2015 x64 Native Tools Command Prompt.lnk`, so I tried with `Developer Command Prompt for VS2015` instead.

            2. While installing VS 2015 on Win 10, we have to select `Microsoft SDK under Windows > Windows 8.1> `

            • VS2015 x64 Native Tools Command Prompt is shortcut created in start menu after installation of Visual Studio 2015 Update 3. We can get same effect (setting of environment) from normal command prompt by using following command [“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat” amd64].
              Did you build tensorflow on windows successfully? I want to know if the tutorial above worked for you.

            • >“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat” amd64

              #The system cannot find the path specified.

              We installed X64 version of VS right? Wouldn’t it be under Program Files and not Program Files (x66)

              and nope, it didn’t build.

            • Hi, Actually Visual Studio is 32 bit program but x64 bit VS include 64 bit compiler toolset. I think you have not installed VS with custom settings and not installed Visual C++ and Python Tools under programming language. Please check. Please read step 2 carefully. Also delete all files and start from step 9 might fix problem. There is alternative way at end too using pre-built pip package.

            • If the file build/zlib/install/bin/zlib.dll exists then you can ignore that error the build process should continue.

  2. Is there any way to build Tensorflow using Visual Studio 2013? I followed this tutorial with path change to Visual Studio 12 2013 Win64. It’s OK when configure using CMake, but failed when building using MSbuild. (It’s work when using VS 2015) Is there anything I can try?

    • I have not tested with Visual Studio 2013 yet. But if you want to build it than uninstall other visual studio because defining visual studio path in cmake only works for tensorflow solution but dependencies required by tensorflow will automatically select latest other version of visual studio which may give error. Please build with command “MSBuild /p:Configuration=Release /verbosity:detailed tf_python_build_pip_package.vcxproj” and comment the error.

    • Hi. It may take 6-7 hours. Disabling realtime protection and other running programs may speed up the build process.

  3. After failing to build a new Tensorflow I managed to get the latest Cuda Toolkit 9.1 work together with the Tensorflow downloaded from the alternative method above. Just copy all DLLs in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin which have names ending with ’91’ to new DLLs ending with ’90’. All works perfectly after that.

    • Thank you for the information. This may prove to be helpful for others as well. By the way, what error did you encounter while building tensorflow?

      • Sorry, I don’t remember now. After about 20 mins of building, the process stopped and there were many red lines. It might have been wrong paths, for I had to install VS2015 and tensorflow on drive D: due to a lack of room on drive C:. Anyway I removed VS2015 after having succeeded with renaming DLLs.

    • Thank you so much for the hint! I did not succeed in the building the .whl file, but ran into your comment and got it done so fast! Awesome!

  4. Can anyone share their working python wheel, please (on github, for example)?

    Ideally using the released Tensorflow 1.5.0, CUDA 9.1, AVX optimizations.

    Cheers 🙂

  5. Thank you for your tutorial. I received this error message after the code was trying to build tensorflow using MSbuild. Could you please help me to resolve it?
    C:\tensorflow\tensorflow\python\eager\ error C2440: ‘=’: cannot convert from ‘const char *’ to ‘char *’ [C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal_static.vcxproj]
    C:\tensorflow\tensorflow\python\eager\ error C2440: ‘return’: cannot convert from ‘const char
    *’ to ‘char *’ [C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal_static.vcxproj]
    C:\tensorflow\tensorflow\python\lib\core\ error C2440: ‘=’: cannot convert from ‘const char *’
    to ‘char *’ [C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal_static.vcxproj]
    C:\tensorflow\tensorflow\python\lib\core\ error C2440: ‘=’: cannot convert from ‘const char *’ to ‘ch
    ar *’ [C:\tensorflow\tensorflow\contrib\cmake\build\pywrap_tensorflow_internal_static.vcxproj]

    • hello, are you using Visual Studio 2017? On Windows 10 Visual Studio 2015 Update 3 (Visual Studio 2017 Uninstalled) should build it successfully. Also the tutorial is updated.

      • Thank you for your reply. I have uninstalled the VS 2017 and installed 2015 Update 3. However, there are still the same errors. Please guide me which step should I rollback? Thank you very much.

        • Delete build and clear temp dir and then start from step 7. Also c drive should have enough space. You can use prebuilt whl tool in case.

  6. 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

  7. 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

  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 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.

  10. 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.

  11. 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.

  12. 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!

  13. 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?

  14. 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.

  15. 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

Leave a Reply

Your email address will not be published.