TensorFlow C + + library process logging under Windows compilation

Source: Internet
Author: User

1. Preparation
  • Windows 10 system, 3.6GHZ CPU, 16G memory
  • Visual Studio or 2015
  • Download and install Git
  • Download and install CMake
  • Download Install Swigwin If you do not need Python bindings, you can skip
  • Clone TensorFlow
  • Switch TensorFlow to the git tag you want to compile
  • Modify Tensorflow/contrib/cmake/cmakelists.txt
    if(Tensorflow_optimize_for_native_arch) include (Checkcxxcompilerflag) Check_cxx_compiler_flag ("-march=native"compiler_opt_arch_native_supported)if(compiler_opt_arch_native_supported)Set(Cmake_cxx_flags"${cmake_cxx_flags}-march=native") # Add this section belowElse() Check_cxx_compiler_flag ("/ARCH:AVX"compiler_opt_arch_avx_supported)if(compiler_opt_arch_avx_supported)Set(Cmake_cxx_flags"${cmake_cxx_flags}/ARCH:AVX") endif () # End of Add below this section endif () endif ()

2. Steps
    1. CMD run vcvarsall.bat AMD64 set specified environment parameters
    2. CD Catalog: Tensorflow\contrib\cmake
    3. Create a build directory, CD build
    4. CMake command

      1. cmake .. -G "Visual Studio 15 2017 Win64" -T host=x64 -DCMAKE_BUILD_TYPE=Release ^
      2. -Dtensorflow_VERBOSE=ON ^
      3. -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF ^
      4. -Dtensorflow_BUILD_PYTHON_BINDINGS=OFF ^
      5. -Dtensorflow_BUILD_CC_EXAMPLE=OFF ^
      6. -Dtensorflow_BUILD_SHARED_LIB=ON ^
      7. -Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX
      8. #-DSWIG_EXECUTABLE=swig.exe的路径
      9. #-DPYTHON_EXECUTABLE=python.exe的路径(anaconda3路径/python.exe)
      10. #-DPYTHON_LIBRARIES=python35.lib的路径(anaconda3路径/libs/python35.lib)

      The above command explains:
      -g Specifies the build target version. command line input cmake-g, you can view the optional version list.
      T-Host=64 is one of the many tutorials on the web that I have previously compiled with VS2017 because I did not specify-t host=64, resulting in a 32-bit compiler with fatal error C1060: "The compiler has insufficient heap space" errors.
      Tensorflow_verbose compile-time output specific information, set to on a bit to reduce the compilation speed.
      Tensorflow_enable_grpc_support GRPC Support, if you have a server/client business need, or cross-language GRPC usage requirements, select on.
      Tensorflow_build_python_bindings needs to compile the PYTHON package, select on.
      Tensorflow_build_cc_example compile the test code.
      Tensorflow_build_shared_lib compile the shared library.
      TENSORFLOW_WIN_CPU_SIMD_OPTIONS=/ARCH:AVX2 Select AVX or AVX2, depending on whether your CPU supports the instruction set.
      Tensorflow_enable_gpu whether the GPU is used for compilation.
      The Tensorflow_optimize_for_native_arch can be set to off or not, and will be automatically judged.
      Other optional parameters can be viewed in the tensorflow\tensorflow\contrib\cmake\cmakelists.txt, and for the parameters you are unsure about, keep them by default.

    5. Compile
      MSBuild /p:Configuration=Release /p:Platform=x64 /verbosity:detailed tensorflow.vcxproj
      这里强调一点,Configuration定义的要与cmake时DCMAKE_BUILD_TYPE定义相同

    6. Run Tests

TensorFlow C + + library process logging under Windows compilation

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.