Building TensorFlow from source on Ubuntu 14.04 LTS: gcc: internal compiler error: Killed (program cc1plus)

Building TensorFlow from source on Ubuntu 14.04 LTS: gcc: internal compiler error: Killed (program cc1plus)

我已经在 Debian 下从源代码成功构建了 TensorFlow,但目前无法使用 Ubuntu 14.04 LTS. IIRC for Debian I tried g++/gcc 5.2 but had to downgrade to g++/gcc 4.9 and it worked. Following the instructions Installing from sources 从新虚拟机开始构建它,如果我安装 g++,版本是 4.8,但它失败了。

gcc: internal compiler error: Killed (program cc1plus)

4.9还没累

我查看了上次Jenkins build but could not find anything listed for the tools and their versions. Even opened issue: Build tools and versions listed in Jenkins build log

的信息

什么版本的 g++/gcc 可以工作?
构建机器使用什么版本的 g++/gcc?

编辑

找到这个:TensorFlow.org Continuous Integration

问题不在于 g++/gcc 版本,而在于 Bazel 用于构建 TensorFlow 的 CPU 个内核数。

运行在 VMware Workstation 7.1 上使用全新安装的 Ubuntu 14.04 LTS 与一个 CPU 内核、2G 内存、2G 交换分区和 2G 交换文件进行多次构建构建 运行 最快。这可能不是最好的设置,但却是迄今为止我发现的始终如一的最佳设置。如果我通过 VMware 允许 4 个内核并使用 Bazel 构建它会失败。如果我使用

使用 Bazel 选项 --local_resources 限制资源
--local_resources 2048,2.0,1.0

构建成功

INFO: Elapsed time: 11683.908s, Critical Path: 11459.26s

使用

--local_resources 4096,2.0,1.0

构建成功

INFO: Elapsed time: 39765.257s, Critical Path: 39578.52s

使用

--local_resources 4096,1.0,1.0

构建成功

INFO: Elapsed time: 6562.744s, Critical Path: 6443.80s

使用

--local_resources 6144,1.0,1.0

构建成功

INFO: Elapsed time: 2810.509s, Critical Path: 2654.90s

总而言之,更多内存和更少 CPU 核心最适合我的环境。

TLDR;

在构建过程中密切关注时,我注意到某些源文件需要很长时间才能编译,并且在构建时似乎会限制流量。就好像它们在与其他源文件竞争资源,而 Bazel 不知道这个关键资源,所以它允许竞争文件同时编译。因此,与未知资源竞争的文件越多,构建速度就越慢。