【问题标题】:CMake build Tensorflow C++ on Windows 10 Error : Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - failedCMake 在 Windows 10 上构建 Tensorflow C++ 错误:测试 COMPILER_OPT_ARCH_NATIVE_SUPPORTED - 失败
【发布时间】:2018-12-03 00:12:42
【问题描述】:

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

系统信息

  • 操作系统平台和发行版(例如,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,顺便说一句

描述问题 我正在关注https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/cmake 的“逐步 Windows 构建”。但是,在第 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

【问题讨论】:

    标签: c++ windows tensorflow cmake


    【解决方案1】:

    指南的第一行指出:

    CMAKE 版本已被 TensorFlow 弃用。请使用 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 中的脚本问题导致无法正确解析源文件之一。在我看来,这些问题是无关的。

    【讨论】:

    • 谢谢弗雷德!我已按照您发布的链接进行操作,并在 CMakeLists.txt 中将 -march=native 替换为 /arch:[AVX|AVX2],但仍然收到 Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed。我在这里做错什么了吗?你有什么建议吗?再次感谢。
    猜你喜欢
    • 2018-04-18
    • 2020-10-09
    • 1970-01-01
    • 2021-11-27
    • 2013-02-25
    • 2017-02-18
    • 1970-01-01
    • 1970-01-01
    • 2018-03-30
    相关资源
    最近更新 更多