Failed to Download go_sdk During TensorFlow 2.13.0 Compilation
Symptom
When compiling TensorFlow 2.13.0, a message is displayed indicating that the go_sdk dependency fails to be downloaded. The details are as follows:
INFO: Repository go_sdk instantiated at:
/path/to/tensorflow-2.13.0/WORKSPACE:23:14: in <toplevel>
/path/to/tensorflow-2.13.0/tensorflow/workspace0.bzl:135:20: in workspace
/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/com_github_grpc_grpc/bazel/grpc_extra_deps.bzl:36:27: in grpc_extra_deps
/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/io_bazel_rules_go/go/private/sdk.bzl:431:28: in go_register_toolchains
/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/io_bazel_rules_go/go/private/sdk.bzl:130:21: in go_download_sdk
Repository rule _go_download_sdk defined at:
/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/io_bazel_rules_go/go/private/sdk.bzl:117:35: in <toplevel>
WARNING: Download from https://golang.org/dl/?mode=json&include=all failed: class java.io.IOException Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out"
WARNING: Download from https://golang.google.cn/dl/?mode=json&include=all failed: class java.io.IOException Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out"
ERROR: An error occurred during the fetch of repository 'go_sdk':
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/io_bazel_rules_go/go/private/sdk.bzl", line 71, column 21, in _go_download_sdk_impl
ctx.download(
Error in download: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/go_sdk/versions.json: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out"
ERROR: /path/to/tensorflow-2.13.0/WORKSPACE:23:14: fetching _go_download_sdk rule //external:go_sdk: Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/io_bazel_rules_go/go/private/sdk.bzl", line 71, column 21, in _go_download_sdk_impl
ctx.download(
Error in download: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/go_sdk/versions.json: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out"
ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/go_sdk/versions.json: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out"
INFO: Elapsed time: 289.584s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (298 packages loaded, 4399 targets configured)
Key Process and Cause Analysis
Key error information: Access times out during the download.
1 | Error in download: java.io.IOException: Error downloading [https://golang.org/dl/?mode=json&include=all, https://golang.google.cn/dl/?mode=json&include=all] to /root/.cache/bazel/_bazel_root/dcb36252f49837fd7a0e106d550e0fdb/external/go_sdk/versions.json: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 504 Gateway Time-out" |
Root cause analysis: https://golang.org/dl/?mode=json&include=all and https://golang.google.cn/dl/?mode=json&include=all are unreachable from the network.
The "HTTP/1.1 504 Gateway Timeout" error indicates that after the client sends a request, the server, functioning as a gateway or proxy, does not receive a response from the upstream server or backend server in a long time. This error is usually caused by the long response time of the upstream server or backend server or the failure to respond. The possible causes include network congestion, high server load, and DNS resolution problems.
Conclusion and Solution
- Check the network configuration and ensure that the compilation server can access https://golang.org and https://golang.google.cn.
- Check whether the addresses are reachable.
1 2
curl https://golang.org -k curl https://golang.google.cn -k

The preceding figure shows that the addresses are unreachable.
- Reconfigure the network proxy by following instructions in Configuring a Network Proxy.
- Check the network configuration and ensure that the addresses are reachable. (Run the preceding command to check whether the addresses are reachable.)
If the addresses are reachable, the following information is displayed:

- Check whether the addresses are reachable.
- Recompile TensorFlow when the network connection is normal.
1 2
bazel clean bazel build //tensorflow/tools/pip_package:build_pip_package