CMake在Windows 10上构建Tensorflow C ++错误:测试COMPILER_OPT_ARCH_NATIVE_SUPPORTED-失败

时间:2018-12-03 00:12:42

标签: c++ windows tensorflow cmake

我想使用CMake在Windows 10上构建Tensorflow C ++。但是,我无法通过COMPILER_OPT_ARCH_NATIVE_SUPPORTED测试,这导致构建尝试失败。这是我在tf github repo上的未解决问题:https://github.com/tensorflow/tensorflow/issues/24076,该问题未得到任何回应,因此为什么我要问stackoverflow并希望这里有人能启发我。我的想法不多了。我曾在Visual Studio 2017和2015中尝试过Python 3.5和3.6。但都没有成功。

系统信息

  • OS平台和发行版(例如Linux Ubuntu 16.04):Windows 10

  • 从(源或二进制)安装的TensorFlow:源

  • TensorFlow版本:最新版本
  • Python版本:3.6
  • Bazel版本(如果从源代码编译):我正在使用CMake
  • GCC /编译器版本(如果从源代码编译):gcc 6.30
  • CUDA / cuDNN版本:仅安装CPU版本
  • 我还使用了Microsoft Visual Studio Community 2017版本15.9.3,btw

描述问题 我正在遵循https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake中的“逐步Windows Build”。但是,在第3步中,我似乎无法通过Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED,从而导致构建过程失败。

提供在遇到问题之前执行的命令/步骤的确切顺序

PS C:\Users\bw\tensorflow\tensorflow\contrib\cmake\build> cmake .. -A x64 -Thost=x64 -DCMAKE_BUILD_TYPE=Release `
>> -DSWIG_EXECUTABLE='C:\Program Files\swigwin-3.0.12\swig.exe' `
>> -DPYTHON_EXECUTABLE='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe' `
>> -DPYTHON_LIBRARIES='C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\libs\python36.lib'
-- Building for: Visual Studio 15 2017
CMake Warning at CMakeLists.txt:9 (message):
  Your current cmake generator is set to use 32 bit toolset architecture.
  This may cause "compiler out of heap space" errors when building.  Consider
  using the flag -Thost=x64 when running cmake.


-- The C compiler identification is MSVC 19.16.27024.1
-- The CXX compiler identification is MSVC 19.16.27024.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED
-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed
-- Performing Test MSVC_OPENMP_SUPPORT
-- Performing Test MSVC_OPENMP_SUPPORT - Success
-- Found PythonInterp: C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/python.exe (found version "3.6.7")
-- Found PythonLibs: optimized;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36.lib;debug;C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64/libs/python36_d.lib (found version "3.6.7")
-- Found SWIG: C:/Program Files/swigwin-3.0.12/swig.exe (found version "3.0.12")
CMake Error at tf_python.cmake:811 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:583 (include)


CMake Error at tf_python.cmake:812 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:583 (include)


CMake Error at tf_python.cmake:813 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:583 (include)


-- Configuring incomplete, errors occurred!
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/bw/tensorflow/tensorflow/contrib/cmake/build/CMakeFiles/CMakeError.log".

其他任何信息/日志

CMakeOutput.log:https://www.dropbox.com/s/7fweyunxdbmxa1k/CMakeOutput.log?dl=0 CMakeError.log:https://www.dropbox.com/s/tucx0tl6346kdpd/CMakeError.log?dl=0

1 个答案:

答案 0 :(得分:1)

指南的第一行指出:

  

TensorFlow不建议使用CMAKE构建。请使用bazel为所有平台构建TF。有关详细信息,请参见TensorFlow安装指南。

显然,您需要使用一个已知通过Windows上的CMAKE正确构建的发行版。如果要构建最新的代码,可能应该切换到推荐的构建系统。

查看此项目的CMakeLists.txt文件,表明Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed是检查编译器是否接受-march=native标志的步骤。不需要,请参见此修复程序https://github.com/tensorflow/tensorflow/issues/8724#issuecomment-289326917

实际错误是由于tf_python.cmake中的脚本问题导致无法正确解析其中一个源文件。在我看来,这些问题是无关的。