简体   繁体   English

如何使用Bazel编译tensorflow以链接已编译的grpc库?

[英]How to compile tensorflow to link already compiled grpc library using bazel?

I cloned tensorflow (version 1.2) from github repo. 我从github repo克隆了tensorflow(1.2版)。 I am having some problem with grpc in distributed tensorflow. 我在分布式张量流中的grpc有问题。 Basically I want to compile tensorflow (1.2) with latest grpc library. 基本上我想用最新的grpc库编译tensorflow(1.2)。

I downloaded and compiled grpc library so I have library files and the headers. 我下载并编译了grpc库,所以我有库文件和标头。 How do I instruct bazel to take this already compiled library files and headers, while building tensorflow. 我如何指示bazel在构建tensorflow时采用已编译的库文件和头文件。

There's no easy way. 没有简单的方法。 If I were to do this, I'd clone tensorflow, and update tensorflow/workspace.bzl to pull newer grpc version, or replace patched_http_archive with new_local_repository or new_http_archive . 如果要这样做,我将克隆tensorflow,并更新tensorflow / workspace.bzl以获取较新的grpc版本,或者将patched_http_archive替换为new_local_repositorynew_http_archive I assume you'd need to apply the patch from third_party/grpc . 我认为您需要应用third_party/grpc的补丁。 Then you should be able to build tensorflow using default procedure: ./configure , and bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package . 然后,您应该能够使用默认过程构建tensorflow: bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package ./configurebazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

Quickly scanning through tensorflow BUILD files it seems tensorflow uses third_party dependencies of grpc (eg nanopb ), so having a compiled library and headers wouldn't be enought anyway. 快速浏览tensorflow的BUILD文件,似乎tensorflow使用了grpc的第三方依赖关系(例如nanopb ),因此拥有已编译的库和标头仍然是不够的。 If you insisted on using your prebuilt grpc, you'd need to provide these dependencies, and update BUILD files and WORKSPACE file. 如果您坚持使用预建的grpc,则需要提供这些依赖项,并更新BUILD文件和WORKSPACE文件。 Bazel doesn't have this feature 'replace repository with its outputs' built-in yet. Bazel尚未内置此功能“用输出替换存储库”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM