---
title: 编译TensorFlow 2.13.0时go_sdk下载失败的解决办法
description: "编译TensorFlow 2.13.0时提示下载依赖组件go_sdk失败，详细信息如下："
url: https://www.hikunpeng.com/document/detail/zh/SRA/ecosystemEnable/TensorFlow/kunpengtensorflow_02_0013.html
sourcePath: /source/zh/SRA/ecosystemEnable/TensorFlow/kunpengtensorflow_02_0013.html
indexId: b3e3f7627b145619874d878d82d0fb4d3bcf82eec2048cd6e57f7d398883d10572
---
# 编译TensorFlow 2.13.0时go_sdk下载失败的解决办法

#### 问题现象描述

编译TensorFlow 2.13.0时提示下载依赖组件go_sdk失败，详细信息如下：

```
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)
```


#### 关键过程、根本原因分析

关键错误信息：执行下载任务，访问超时。

```
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"
```

根本原因分析：无法访问https://golang.org/dl/?mode=json&include=all和https://golang.google.cn/dl/?mode=json&include=all，网络不可达。

HTTP/1.1 504 Gateway Timeout错误表示客户端发出请求后，服务器作为网关或者代理，等待了一段时间后未能从上游服务器或者后端服务器接收到响应。这种错误通常是由于上游服务器或者后端服务器的响应时间过长或者未能响应导致的。可能的原因包括网络拥堵、服务器负载过高、DNS解析问题等。


#### 结论、解决方案及效果

1. 请检查网络配置，确认通过编译服务器可以访问https://golang.org和https://golang.google.cn。

  a. 确认网络是否可达。
    1 2 curl https://golang.org -k curl https://golang.google.cn -k

    上图表示网络不可达。

  b. 请参见    配置网络代理
重新配置网络代理。
  c. 检查网络配置，保证网络可达（通过上述命令确认网络可达）。
    网络可达会显示如下图所示信息。

2. 网络畅通情况下，重新编译TensorFlow。
  1 2 bazel clean bazel build //tensorflow/tools/pip_package:build_pip_package
