Tensorflow r1.3 윈도우10에서 C++ 컴파일 수행기 (x64)

enuSpace for jupiter - work note


Tensorflow r1.3을 이용한 Third party 프로그램 개발에 있어 소스 빌드과정에 대한 수행 내용이다.



Tensorflow r1.3 컴파일 공식 페이지

https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/contrib/cmake/README.md



Step by Step


Run cmd (컴파일 환경 설정)

- D:\Workspace>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"


CMake and git Path 추가 (Cmd 창에서 명령  수행이 가능하도록 패스추가)

- D:\Workspace>set PATH=%PATH%;C:\Program Files\Git\bin\


cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^

-DSWIG_EXECUTABLE=D:/Workspace/swigwin-3.0.10/swigwin-3.0.10/swig.exe ^

-DPYTHON_EXECUTABLE=C:/Anaconda3/python.exe ^

-DPYTHON_LIBRARIES=C:/Anaconda3/libs/python35.lib ^

-Dtensorflow_ENABLE_GPU=ON ^

-DCUDNN_HOME="D:\Workspace\cudnn-8.0-windows10-x64-v5.1\cuda" ^

-Dtensorflow_WIN_CPU_SIMD_OPTIONS=/arch:AVX


MSBuild /p:Configuration=RelWithDebInfo ALL_BUILD.vcxproj

텐서플로우 실행 절차에 수행시 error : new line constant 에러가 발생합니다.

아래와 같이 조치를 수행합니다.


-----------------------------------------------------------------------------------------------

build\re2\src\re2\CMakeLists.txt 파일 오픈 수행후 AdditionalOptions 을 추가합니다. (/source-charset:utf-8)



# Copyright 2015 The RE2 Authors.  All Rights Reserved.

# Use of this source code is governed by a BSD-style

# license that can be found in the LICENSE file.


# Old enough to support Ubuntu Trusty.

cmake_minimum_required(VERSION 2.8.12)


project(RE2 CXX)

include(CTest)


option(BUILD_SHARED_LIBS "build shared libraries" OFF)

option(USEPCRE "use PCRE in tests and benchmarks" OFF)


# CMake seems to have no way to enable/disable testing per subproject,

# so we provide an option similar to BUILD_TESTING, but just for RE2.

option(RE2_BUILD_TESTING "enable testing for RE2" ON)


set(EXTRA_TARGET_LINK_LIBRARIES)


if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

  if(MSVC_VERSION LESS 1800)

    message(FATAL_ERROR "you need Visual Studio 2013 or later")

  endif()

  if(BUILD_SHARED_LIBS)

    # See http://www.kitware.com/blog/home/post/939 for details.

    cmake_minimum_required(VERSION 3.4)

    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

  endif()

  # CMake defaults to /W3, but some users like /W4 (or /Wall) and /WX,

  # so we disable various warnings that aren't particularly helpful.

  add_compile_options(/source-charset:utf-8 /wd4100 /wd4201 /wd4456 /wd4457 /wd4702 /wd4815)

elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")

  add_compile_options(-std=c++11)

endif()





RELEASE용 컴파일 수행합니다.


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




+ Recent posts