在Windows 10上使用CMake构建TensorFlow时出错

时间:2017-05-12 15:02:01

标签: tensorflow msbuild cmake windows-10

我在Windows上尝试TensorFlow CMake build,但我遇到了问题。

首先,我跑

C:\work\tensorflow\tensorflow\contrib\cmake\build>cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
More? -DSWIG_EXECUTABLE=C:/Program1/swigwin-3.0.12/swig.exe ^
More? -DPYTHON_EXECUTABLE=C:/Python3.5/python.exe ^
More? -DPYTHON_LIBRARIES=C:/Python3.5/libs/python35.lib ^
More? -Dtensorflow_ENABLE_GPU=ON ^
More? -DCUDNN_HOME="C:\Program1\cudnn\cuda"

并获取输出

-- Building for: Visual Studio 14 2015
-- The C compiler identification is MSVC 19.0.24215.1
-- The CXX compiler identification is MSVC 19.0.24215.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/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
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0 (found suitable version "8.0", minimum required is "8.0")
-- Found PythonInterp: C:/Python3.5/python.exe (found version "3.5")
-- Found PythonLibs: C:/Python3.5/libs/python35.lib (found version "3.5.0")
-- Found SWIG: C:/Program1/swigwin-3.0.12/swig.exe (found version "3.0.12")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/tensorflow/tensorflow/contrib/cmake/build

这里唯一令人不安的是-- Performing Test COMPILER_OPT_ARCH_NATIVE_SUPPORTED - Failed,我不知道这意味着什么,或者这是一个严重的问题。 (是吗?

其次,我跑

MSBuild /p:Configuration=Release tf_tutorials_example_trainer.vcxproj

这给了我几个错误:

"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj" (default target) (90) ->
(CustomBuild target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj]


"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj" (default target) (91) ->
(ClCompile target) ->
  c:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.h(24): fatal error C1083: Cannot open include file: 'cuda/include/cusolverDn.h': No such file or directory (compiling source file C:\work\tensorflow\tensorflow\core\kernels\cholesky_op.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]
  c:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.h(24): fatal error C1083: Cannot open include file: 'cuda/include/cusolverDn.h': No such file or directory (compiling source file C:\work\tensorflow\tensorflow\core\kernels\cuda_solvers.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]
  c:\work\tensorflow\tensorflow\contrib\cmake\build\external\eigen_archive\eigen\src\core\coreevaluators.h(1052): fatal error C1060: compiler is out of heap space (compiling source file C:\work\tensorflow\tensorflow\core\kernels\svd_op_float.cc) [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_kernels.vcxproj]

    696 Warning(s)
    4 Error(s)

我不知道MSBuild在哪个文件夹中查找cuda/include/cusolverDn.h。我在cuda中没有任何名为c:\work\tensorflow\tensorflow\core\kernels的文件夹,cusolverDn.h存储库中的任何位置都没有名为tensorflow的文件。 (不过,我在CUDA安装目录中确实有cusolverDn.h文件。)所以,

如何让MSBuild找到cusolverDn.h?我该怎么做才能防止编译器耗尽堆空间?

在先前尝试运行最后一个命令时,我也收到了消息

nvcc fatal   : Microsoft Visual Studio configuration file 'vcvars64.bat' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/../..'

有人建议renaming a folder and a file in that folder。我无法真正验证这是否正常工作,因为问题暂时似乎已经消失(可能是由于“编译器没有堆空间”问题掩盖了,我之前没有这个问题......)。

是否正确重命名此文件和此文件夹?

1 个答案:

答案 0 :(得分:1)

根据tensorflow instructions检查以下内容:

  • 您必须为Visual Studio运行64位启用的命令提示符;你应该从这样的提示中运行你的msbuild.exe命令;
  • 安装CUDNN的Nvidia zio文件并将其/ bin /目录附加到PATH环境变量,它应包含两个类似于以下内容的条目:
    • D:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ bin
    • d:\ YOURCUDNNPATH \ CUDA \ BIN
  • 检查PATH中是否有gitcmake命令;检查是否可以从提示符运行这些命令;