TensorFlow Windows Build with GPU support

Source: Internet
Author: User
Tags cuda toolkit microsoft windows 10

Step-by-Step Windows Build

Although I have been using Caffe, and the use of the fly, but still very concerned about the TensorFlow community, recently found that TF has a version of Windows, they have tried.

Step: Https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake

Pre-requisites:

Microsoft Windows 10

    • Microsoft visual Studio Enterprise with Visual C + + 2015
    • Anaconda 4.1.1 (Python 3.5 64-bit)
    • Git for Windows version 2.9.2.windows.1
    • swigwin-3.0.10
    • NVidia CUDA Toolkit 8.0
    • NVidia CUDNN 5.1
  1. Install The pre-requisites detailed above, and set up your environment.

    • The following commands assume that is using the Windows Command Prompt ( cmd.exe ). You'll need to set up your environment to use the appropriate toolchain, i.e. the 64-bit tools. (Some of the binary targets we'll build is too large for the 32-bit tools, and they would fail with out-of-memory errors .) The typical command to does set up your environment is:

      D:\temp> "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvarsall.bat"
    • When building and GPU support after installing the CUDNN zip file from NVidia, append it bin directory to your PATH envi Ronment variable. In case TensorFlow fails to find the CUDA DLL ' s during initialization, check your PATH environment variable. It should contain the directory of the CUDA DLLs and the directory of the CUDNN DLL. For example:

      D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\binD:\local\cuda\bin
    • We assume that and is installed and in cmake git your %PATH% . If For example isn't in cmake your path and it's installed C:\Program Files (x86)\CMake\bin\cmake.exe in, can add this directory to your as %PATH% follows :

      D:\temp> set PATH="%PATH%;C:\Program Files (x86)\CMake\bin\cmake.exe"
  2. Clone the TensorFlow repository and create a working directory for your build:

    D:\temp> git clone https://github.com/tensorflow/tensorflow.gitD:\temp> cd tensorflow\tensorflow\contrib\cmakeD:\temp\tensorflow\tensorflow\contrib\cmake> mkdir buildD:\temp\tensorflow\tensorflow\contrib\cmake> cd buildD:\temp\tensorflow\tensorflow\contrib\cmake\build>
  3. Invoke CMake to create Visual Studio solution and project files.

    N.B. This assumes, that's in cmake.exe your %PATH% environment variable. The other paths is for illustrative purposes only, and may is different on your platform. The character is a line continuation and must are the last character on each line ^ .

    To build with GPU support add "^" at the end of the above following with:

    More? -Dtensorflow_ENABLE_GPU=ON ^More? -DCUDNN_HOME="D:\...\cudnn"

    Note that the -DCMAKE_BUILD_TYPE=Release flag must match the build configuration that is choose when invoking msbuild . The Known-good values are Release and RelWithDebInfo . DebugThe build type is not currently supported, because it relies in a Debug library for Python () that's not python35d.lib Distr Ibuted by default.

    There is various options that can is specified when generating the solution and project files:

    • -DCMAKE_BUILD_TYPE=(Release|RelWithDebInfo): Note that the CMAKE_BUILD_TYPE option must match the build configuration so you choose when invoking MSBuild in step 4. The Known-good values are Release and RelWithDebInfo . DebugThe build type is not currently supported, because it relies in a Debug library for Python () that's not python35d.lib Distr Ibuted by default.

    • -Dtensorflow_BUILD_ALL_KERNELS=(ON|OFF). Defaults to ON . You can build a small subset of the kernels for a faster build by setting this option to OFF .

    • -Dtensorflow_BUILD_CC_EXAMPLE=(ON|OFF). Defaults to ON . Generate project files for a simple C + + example training program.

    • -Dtensorflow_BUILD_PYTHON_BINDINGS=(ON|OFF). Defaults to ON . Generate project files for building a PIP package containing the TensorFlow runtime and its Python bindings.

    • -Dtensorflow_ENABLE_GRPC_SUPPORT=(ON|OFF). Defaults to ON . Include GRPC Support and the distributed client and server code in the TensorFlow runtime.

    • -Dtensorflow_ENABLE_SSL_SUPPORT=(ON|OFF). Defaults to OFF . Include SSL Support (for making secure HTTP requests) in the TensorFlow runtime. This is incomplete, and would be used for Google Cloud Storage support.

    • -Dtensorflow_ENABLE_GPU=(ON|OFF). Defaults to OFF . Include GPU Support. If GPU is enabled for you need to install the CUDA 8.0 Toolkit and CUDNN 5.1. CMake would expect the location of CUDNN In-dcudnn_home=path_you_unziped_cudnn.

    • -Dtensorflow_BUILD_CC_TESTS=(ON|OFF). Defaults to OFF . This builds CC unit tests. There is many of them and building would take a few hours. After CMake, build and execute the tests with

      MSBuild /p:Configuration=RelWithDebInfo ALL_BUILD.vcxprojctest -C RelWithDebInfo
    • -Dtensorflow_BUILD_PYTHON_TESTS=(ON|OFF). Defaults to OFF . This enables Python kernel tests. After building the Python wheel, you need to install the new wheel before running the tests. To execute the tests, use

      ctest -C RelWithDebInfo
  4. Invoke MSBuild to build TensorFlow.

    To build the C + + example program, which is created as a executable in the .exe subdirectory .\Release :

    D:\...\build> MSBuild /p:Configuration=Release tf_tutorials_example_trainer.vcxprojD:\...\build> Release\tf_tutorials_example_trainer.exe

    To build the PIP package, which'll be created as a .whl file in the subdirectory .\tf_python\dist :

    D:\...\build> MSBuild /p:Configuration=Release tf_python_build_pip_package.vcxproj

There was a mistake in the fourth, because of the tensorflow\tensorflow\contrib\cmake\build\cmakefiles\tf_core_gpu_kernels.dir\__\. There is a problem with the CMake file generated below, the solution is: line 81 at __version__= "MSVC" to Change to __version__=\ "Msvc\"

After changing the step 4 to generate the WHL file, pip install *.WHL start playing ...

TensorFlow Windows Build with GPU support

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.