天天看点

bazel build tensorflow over proxy

在使用bazel编译tensorflow和tensorflow/tools/graph_transforms:transform_graph的过程中,出现某些资源无法下载的情况。

如:

bazel build tensorflow/tools/graph_transforms:transform_graph
           

会遇到

Error downloading [
    https://storage.googleapis.com/mirror.tensorflow.org/github.com/aws/aws-sdk-cpp/archive/1.5.8.tar.gz,
    https://github.com/aws/aws-sdk-cpp/archive/1.5.8.tar.gz] to
/home/略略略/.cache/bazel/_bazel_略略略/ae268aa41b50ed3f4ec4a64fae0a392e/external/aws/1.5.8.tar.gz
           

尝试了 tsocks 也不好用。我们去他家问问。

https://github.com/bazelbuild/bazel/search?q=proxy&type=Issues

果然早就出现了,这里

Unfortunately, bazel's download utility and proxies is a known issue.

A quick work around is to manually download the needed files and put them to some directory. Then you can tell bazel using the

--distdir

option to first search there before even going to network, e.g.,

bazel build --distdir /path/to/where/you/put/the/files/ //src:bazel

.

Also, if you have a jdk on your system already (e.g., the one taken from your distribution) there is no need to download one freshly; you can tell bazel to using by providing the option

[email protected]_jdk//:jdk

, i.e.,

bazel build [email protected]_jdk//:jdk //src:bazel

.

所以解决方法很简单,首先,用浏览器或者tsocks wget把需要下载文件弄下来,放在某个文件夹,如

tsocks wget https://github.com/aws/aws-sdk-cpp/archive/1.5.8.tar.gz

tsocks wget https://github.com/unicode-org/icu/archive/release-64-2.zip

然后增加选项  --distdir /home/略略略/Downloads/

tsocks bazel build --distdir /home/略略略/Downloads/ tensorflow/tools/graph_transforms:transform_graph

就可以顺利编译了。

前置条件:

Linux 下有好用的 tsocks 一套。

powershell的话……鬼知道怎么办。

继续阅读