//tensorflow/core/grappler/costs:utils 中的可配置属性 "deps" 的非法模糊匹配:尝试构建具有 GPU 支持的 Tensorflow 时

Illegal ambiguous match on configurable attribute "deps" in //tensorflow/core/grappler/costs:utils: when trying to build Tensorflow with GPU support

我正在尝试使用命令 bazel build --config=opt --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --config=cuda //tensorflow/tools/pip_package:build_pip_package 在 Ubuntu 上构建 Tensorflow,但在 运行 ./configure:

之后出现以下错误
Illegal ambiguous match on configurable attribute "deps" in //tensorflow/core/grappler/costs:utils:
@local_config_cuda//cuda:using_clang
@local_config_cuda//cuda:using_nvcc
Multiple matches are not allowed unless one is unambiguously more specialized.
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted
INFO: Elapsed time: 30.960s
FAILED: Build did NOT complete successfully (91 packages loaded)

我不确定发生了什么。貌似使用clang和nvcc有冲突,但是我觉得我在配置过程中没有在任何地方指定使用nvcc。 ./configure 应该已经顺利完成了。

奇怪的是我无法在互联网上找到任何此类错误报告。

会不会是我 CUDA 安装不正确,还是 tensorflow 配置有问题?

不确定它是否对其他人有帮助,但显然在配置过程中我回答 "yes" 使用 clang 作为编译器。然后我回答 "no" 并使用 gcc 作为 nvcc 的主机;构建完成很好。

您需要在 Bazel 命令中使用 --config=cuda_clang,例如:

bazel build --config=opt --config=cuda_clang //tensorflow/tools/pip_package:build_pip_package 

我也遇到了这个问题,我尝试在 Ubuntu 16.04 上使用不同的编译器编译 TF,有两个选项可以解决这个问题:

1. Do you want to use clang as CUDA compiler? [y/N]选择y,这里使用clang作为后端cuda代码编译器,然后可以使用命令: bazel build --config=opt --config=cuda_clang //tensorflow/tools/pip_package:build_pip_package

2. Do you want to use clang as CUDA compiler? [y/N]选择N,这里使用nvcc作为后端cuda代码编译器,然后可以使用命令: bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package.

CUDA is supported in llvm 3.9, if using clang as the cuda code compiler, clang 3.9 or higher version is needed. You will need CUDA 7.0, 7.5, or 8.0 to compile with clang,暂不支持CUDA 9.0以上版本。 A related topic in TF Github,希望有用。