当我使用gpu支持构建tensorflow时(在configure中我将cuda支持设置为yes),bazel build -c opt --config = cuda // tensorflow / tools / pip_package:build_pip_package一切正常 .
但在我重启系统后,尝试使用上面的命令构建tensorflow,它会给我以下错误:
错误
/home/wolfson/.cache/bazel/_bazel_wolfson/41eaf6c788f09c81cffb135517d04fa2/external/local_config_cuda/crosstool/BUILD:4:1: Traceback (most recent call last):
File "/home/wolfson/.cache/bazel/_bazel_wolfson/41eaf6c788f09c81cffb135517d04fa2/external/local_config_cuda/crosstool/BUILD", line 4
error_gpu_disabled()
File "/home/wolfson/.cache/bazel/_bazel_wolfson/41eaf6c788f09c81cffb135517d04fa2/external/local_config_cuda/crosstool/error_gpu_disabled.bzl", line 3, in error_gpu_disabled
fail("ERROR: Building with --config=c...")
ERROR: Building with --config=cuda but TensorFlow is not configured to build with GPU support. Please re-run ./configure and enter 'Y' at the prompt to build with GPU support.
ERROR: no such target '@local_config_cuda//crosstool:toolchain': target 'toolchain' not declared in package 'crosstool' defined by /home/wolfson/.cache/bazel/_bazel_wolfson/41eaf6c788f09c81cffb135517d04fa2/external/local_config_cuda/crosstool/BUILD.
1 回答
bazel构建检查环境变量TF_NEED_CUDA是否设置为1,否则会报告 . 此变量在configure脚本中导出,但在重新引导后丢失 .
在构建之前执行
export TF_NEED_CUDA=1
可能会解决您的问题,但重启后可能还有其他环境变量或文件丢失 .