Windows 上使用 Cuda 时出现 Tensorflow 1.9 Bazel 构建错误

标签 tensorflow bazel

我正在尝试编译一个使用 Tensorflow 核心的示例程序,并在以下环境中通过 Bazel 在 Windows 10 64 位上提供 CUDA 支持:

  • Windows 10 64 位
  • CUDA 工具包 9.0
  • CUDNN 9.0
  • tensorflow 1.9
  • 巴泽尔0.16

我成功完成了configure.py,添加了CUDA和CUDNN位置。

这是我的 Bazel BUILD 文件:

cc_binary(
  name = "mnistpredict.dll",
  srcs = ["mnist.cc", "MNIST.h"],
  deps = [
      "//tensorflow/core:tensorflow",
  ],
  linkshared=1
)

我尝试使用以下命令进行编译: bazel构建//tensorflow/loadgraph:mnistpredict.dll

ERROR: C:/users/laci/downloads/tensorflow-1.9.0/tensorflow/loadgraph/BUILD:1:1: error loading package 'tensorflow/core': Encountered error while reading extension file 'cuda/build_defs.bzl': no such package '@local_config_cuda//cuda': Traceback (most recent call last): File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 1166 _create_local_cuda_repository(repository_ctx) File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 995, in _create_local_cuda_repository _get_cuda_config(repository_ctx) File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 750, in _get_cuda_config _cudnn_version(repository_ctx, cudnn_install_base..., ...) File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 466, in _cudnn_version find_cuda_define(repository_ctx, cudnn_header_dir, "c...", ...) File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 422, in find_cuda_define auto_configure_fail(("Error reading %s: %s" % (str(h...))) File "C:/users/laci/downloads/tensorflow-1.9.0/third_party/gpus/cuda_configure.bzl", line 210, in auto_configure_fail fail(("\n%sCuda Configuration Error:%...)))

Cuda Configuration Error: Error reading C:/Users/laci/Downloads/cudnn-9.0-windows10-x64-v7.1/cuda/include/cudnn.h: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(239): CreateProcessW("grep" --color=never -A1 -E "#define CUDNN_MAJOR" C:/Users/laci/Downloads/cudnn-9.0-windows10-x64-v7.1/cuda/include/cudnn.h): The system cannot find the file specified.

and referenced by '//tensorflow/loadgraph:mnistpredict.dll' ERROR: Analysis of target '//tensorflow/loadgraph:mnistpredict.dll' failed; build aborted: Analysis failed INFO: Elapsed time: 1.612s INFO: 0 processes. FAILED: Build did NOT complete successfully (2 packages loaded) currently loading: tensorflow/core

当我在没有CUDA支持的情况下尝试时,我可以成功编译它。

最佳答案

它在 %PATH% 下寻找 grep.exe 但失败。将 Git\bin 添加到 %PATH% 或安装适用于 Windows 的 grep 即可解决问题。

我花了几天时间才最终使用 bazel + msys2 在 Windows 7 64 位上构建了一个tensorflow-gpu 1.10 whl。

关于Windows 上使用 Cuda 时出现 Tensorflow 1.9 Bazel 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51534685/

相关文章:

python - 无法在 TensorFlow 中为 GradientDescentOptimizer 收集梯度

plugins - 错误 : Configuration cannot be run until project has been synced

java - 为什么 java_executable_exec_path 给我一个遗留的 "external"运行文件路径

bazel - 将外部依赖项保存到项目存储库

tensorflow - 无法在 Intel i7 930 CPU 上从源代码编译 TensorFlow; GTS-250 显卡

python - 在 Tensorflow 中设置交集

python - 为训练和验证数据提供张量

python - IntelliJ 找不到一些生成的 TensorFlow 引用

c++ - Bazel 构建 C++ 中的 "ambiguous symbol"

python - Bazel:从 py_library 中的 python 文件创建 py_binary