我正在学习本教程 https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android
使用
后的错误sudo bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
ERROR: /home/hugo/.cache/bazel/_bazel_root/1c2dc229a3fb3a0c8f1a06862d6b4c74/external/local_config_cuda/crosstool/BUILD:4:1: Traceback (most recent call last):
File "/home/hugo/.cache/bazel/_bazel_root/1c2dc229a3fb3a0c8f1a06862d6b4c74/external/local_config_cuda/crosstool/BUILD", line 4
error_gpu_disabled()
File "/home/hugo/.cache/bazel/_bazel_root/1c2dc229a3fb3a0c8f1a06862d6b4c74/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/hugo/.cache/bazel/_bazel_root/1c2dc229a3fb3a0c8f1a06862d6b4c74/external/local_config_cuda/crosstool/BUILD.
我也试过用android studio构建,错误是
错误:任务':buildExternalAssets'执行失败。 启动流程问题' / usr / local / bin / bazel''
我检查了/ usr / local / bin /并且那里没有bazel文件夹。
我假设上述错误也是由于我的bazel没有正确安装造成的? 我试过bazel版本并得到了
Build label: 0.4.5
Build target: bazel-out/local-fastbuild/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Mar 16 12:19:38 2017 (1489666778)
Build timestamp: 1489666778
Build timestamp as int: 1489666778
所以我很确定它已经安装好了。 这里有什么错误,我该如何纠正?
答案 0 :(得分:1)
错误:任务':buildExternalAssets'的执行失败。启动进程'command'/ usr / local / bin / bazel''
时出现问题1.这说在“/ usr / local / bin / bazel”找不到bazel,你清楚地知道,正如你所说,“我检查了/ usr / local / bin /并且那里没有bazel文件夹。“
2.请在命令行上通过“whereis bazel”命令检查PC上安装bazel的位置(如果在Linux OS上)
PC:〜$ whereis bazel
bazel:/ usr / bin / bazel /etc/bazel.bazelrc
错误:使用--config = cuda构建,但TensorFlow未配置为使用GPU支持构建。
3.看起来你正在使用针对CUDA的来源,那是你想要做的吗?我的意思是你想在基于CUDA的设备上编译部署源吗?
如果是这样,“请重新运行./configure”
答案 1 :(得分:1)
还有其他选项可用于构建本机库。
您可以尝试使用build.gradle
//设置为' bazel',' cmake',' makefile',' none'
def nativeBuildSystem =' cmake'
最新版本的android能够添加cmake构建工具来构建本机库。
我成功完成了cmake。
答案 2 :(得分:0)
(尝试评论OP的帖子,但业力不足,所以我发帖作为答案。)
whereis
命令返回了两个路径,而不是一个路径:
/usr/bin/bazel
是你的bazel二进制文件。将其设置为您需要的任何变量的路径。
/etc/bazel.bazelrc
是您的bazelrc文件的路径。它是Bazel的配置文件,您可以在其中为bazel命令指定常用标志,例如:如果你总是像bazel build --flag=value //foo
那样构建,那么你可以在这个文件build --flag=value
中添加一个条目,这意味着“build”命令默认使用这个标志,所以你不必每次都输入它。如果您的系统上没有此文件,那么Bazel仍然可以正常工作。在此处阅读更多内容:https://bazel.build/versions/master/docs/bazel-user-manual.html#bazelrc