使用bazel编译工具编译时提示“An error occurred during the fetch of repository 'io_bazel_rules_docker'”,编译失败
问题描述
使用bazel build --config=monolithic //tensorflow/compiler/aot:xlacompilebazel build命令编译过程中,提示“ERROR: An error occurred during the fetch of repository 'io_bazel_rules_docker'”,检查服务器,能够连接网络,但仍旧提示如下错误信息:
ERROR: An error occurred during the fetch of repository 'io_bazel_rules_docker': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_docker/releases/download/v0.14.3/rules_docker-v0.14.3.tar.gz] to /home/test/.cache/bazel/_bazel_test/abd37aaac8a380ca5a3f13938322fcb2/external/io_bazel_rules_docker/rules_docker-v0.14.3.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target ERROR: no such package '@io_bazel_rules_docker//repositories': java.io.IOException: Error downloading [https://github.com/bazelbuild/rules_docker/releases/download/v0.14.3/rules_docker-v0.14.3.tar.gz] to /home/test/.cache/bazel/_bazel_test/abd37aaac8a380ca5a3f13938322fcb2/external/io_bazel_rules_docker/rules_docker-v0.14.3.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target INFO: Elapsed time: 24.586s INFO: 0 processes. FAILED: Build did NOT complete successfully (0 packages loaded)
解决方案
如果连网情况下,仍旧提示上述无法下载压缩包的问题,则请参见如下方法解决:
- 将如下链接中的附件下载到本地,然后上传到linux服务器任意路径,例如上传到$HOME/bazel_tools路径。
https://github.com/bazelbuild/rules_docker/releases/download/v0.14.3/rules_docker-v0.14.3.tar.gz https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz https://github.com/bazelbuild/rules_swift/releases/download/0.11.1/rules_swift.0.11.1.tar.gz https://github.com/llvm-mirror/llvm/archive/7a7e03f906aada0cf4b749b51213fe5784eeff84.tar.gz
则上述文件在linux服务器绝对路径为:/home/test/bazel_tools/rules_docker-v0.14.3.tar.gz /home/test/bazel_tools/bazel-skylib.0.8.0.tar.gz /home/test/bazel_tools/rules_swift.0.11.1.tar.gz /home/test/bazel_tools/llvm-7a7e03f906aada0cf4b749b51213fe5784eeff84.tar.gz
- 修改bazel编译工具相关文件中的下载链接:
- 切换到tensorflow-1.15.0目录,使用vi WORKSPACE命令打开WORKSPACE,修改该文件中的下载链接,将下载链接修改为linux服务器绝对路径地址:
bazel_toolchains_repositories() http_archive( name = "io_bazel_rules_docker", sha256 = "6287241e033d247e9da5ff705dd6ef526bac39ae82f3d17de1b69f8cb313f9cd", strip_prefix = "rules_docker-0.14.3", urls = ["file:///home/test/bazel_tools/rules_docker-v0.14.3.tar.gz"], ) load( "@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories", ) container_repositories() load("//third_party/toolchains/preconfig/generate:workspace.bzl", "remote_config_workspace") remote_config_workspace() # Apple and Swift rules. http_archive( name = "build_bazel_rules_apple", sha256 = "6efdde60c91724a2be7f89b0c0a64f01138a45e63ba5add2dca2645d981d23a1", urls = ["https://github.com/bazelbuild/rules_apple/releases/download/0.17.2/rules_apple.0.17.2.tar.gz"], ) # https://github.com/bazelbuild/rules_apple/releases http_archive( name = "build_bazel_rules_swift", sha256 = "96a86afcbdab215f8363e65a10cf023b752e90b23abf02272c4fc668fcb70311", urls = ["file:///home/test/bazel_tools/rules_swift.0.11.1.tar.gz"], ) # https://github.com/bazelbuild/rules_swift/releases
执行wq!保存退出。
- 修改tensorflow-1.15.0/tensorflow路径下workspace.bzl文件中llvm对应的链接:
# TODO(phawkins): currently, this rule uses an unofficial LLVM mirror. # Switch to an official source of snapshots if/when possible. tf_http_archive( name = "llvm", build_file = clean_dep("//third_party/llvm:llvm.autogenerated.BUILD"), sha256 = "599b89411df88b9e2be40b019e7ab0f7c9c10dd5ab1c948cd22e678cc8f8f352", strip_prefix = "llvm-7a7e03f906aada0cf4b749b51213fe5784eeff84", urls = [ "https://mirror.bazel.build/github.com/llvm-mirror/llvm/archive/7a7e03f906aada0cf4b749b51213fe5784eeff84.tar.gz", "file:///home/test/bazel_tools/llvm-7a7e03f906aada0cf4b749b51213fe5784eeff84.tar.gz", ], )
- 修改完成后,重新切换到tensorflow-1.15.0目录,执行如下命令编译xlacompile工具:
bazel build --config=monolithic //tensorflow/compiler/aot:xlacompile
若提示“ERROR: An error occurred during the fetch of repository 'bazel_skylib':”,则进入下一步继续修改bazel_skylib相关的文件。
- 修改.cache目录中的相关链接:
切换到$HOME目录,使用grep -r bazel-skylib.0.8.0 .cache/命令查看.cache目录哪个文件引用bazel-skylib.0.8.0.tar.gz的url,根据返回信息,进入引用该url文件所在的目录,例如.cache/bazel/_bazel_test/abd37aaac8a380ca5a3f13938322fcb2/external/io_bazel_rules_closure/closure/repositories.bzl(该路径只是样例,请以用户实际编译后的为准)
打开该文件,将其中的url改为:
file:///home/test/bazel_tools/bazel-skylib.0.8.0.tar.gz
执行wq!保存退出。
- 切换到tensorflow-1.15.0目录,使用vi WORKSPACE命令打开WORKSPACE,修改该文件中的下载链接,将下载链接修改为linux服务器绝对路径地址:
父主题: FAQ