Tensorflow 编译运行时间长 [英] Tensorflow Compile Runs For A Long Time
问题描述
所以我试图从源代码编译 TensorFlow
(使用 2019 年 1 月 31 日从他们的 git 存储库中的克隆).我从他们的 shell 脚本(https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-installer-linux-x86_64.sh).
So I am trying to compile TensorFlow
from the source (using a clone from their git repo from 2019-01-31). I installed Bazel from their shell script (https://github.com/bazelbuild/bazel/releases/download/0.21.0/bazel-0.21.0-installer-linux-x86_64.sh).
我在 tensorflow 代码中执行了 ./configure
并提供了默认设置,除了添加我的机器特定的 -m 选项(-mavx2 -mfma)并将 python 指向正确的 python3 位置(/usr/bin/py3).然后我按照 tensorflow 指令运行以下命令:
I executed ./configure
in the tensorflow code and provided the default settings except for adding my machine specific -m options (-mavx2 -mfma) and pointing python to the correct python3 location (/usr/bin/py3). I then ran the following command as per the tensorflow instructions:
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package //tensorflow:libtensorflow_framework.so //tensorflow:libtensorflow.so
现在继续运行和运行,我还没有看到它完成(虽然我被限制让它运行最多大约 10 个小时).它产生大量信息:有关有符号和无符号整数的警告以及控制到达非空函数的末尾.这些似乎都不是致命的.编译继续打勾,两个数字继续增长('[N,NNN/X,XXX] 4 个动作正在运行')和文件打勾通过'编译'.
Now that continues to run and run, I haven't seen it complete yet (though I am limited to letting it run for a maximum of about 10 hours). It produces a ton of INFO: warnings regarding signed and unsigned integers and control reaching the end of non-void functions. None of these appear fatal. Compilation continues to tick with the two numbers continuing to grow ('[N,NNN / X,XXX] 4 actions running') and files ticking through 'Compiling'.
这台机器是一个 EC2 实例,具有 ~16GiB 的 RAM,CPU 是Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz",我相信 4 核,大量的硬盘空间(尽管编译似乎吃一点,> 1GiB)
The machine is an EC2 instance with ~16GiB of RAM, CPU is 'Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz' with I believe 4-cores, plenty of HDD space (although compilation seems to eat QUITE a bit, > 1GiB)
对这里发生的事情有什么想法吗?
Any ideas on what's going on here?
推荐答案
不幸的是,有些程序可能需要很长时间才能编译.几个小时的编译对于您的设置中的 tensorflow 来说并不奇怪.
Unfortunately, some programs can take a long time to compile. A couple of hours of compilation is not strange for tensorflow on your setup.
有报道称它需要 50 分钟在速度相当快的机器上
There are reports of it taking 50 minutes on a considerably faster machine
此问题的解决方案是使用 pip 可用的预编译二进制文件,说明可以在这里找到:https://www.tensorflow.org/install/pip.html
A solution to this problem is to use pre-compiled binaries that are available with pip, instructions can be found here: https://www.tensorflow.org/install/pip.html
基本上你可以这样做:
pip install tensorflow
如果你需要一个特定的旧版本,比如 1.15,你可以这样做:
If you require a specific older version, like 1.15, you can do this:
pip install tensorflow==1.15
对于 gpu 支持,您将 -gpu
添加到包名称,如下所示:
For gpu support you add -gpu
to the package name, like this:
pip install tensorflow-gpu
还有:
pip install tensorflow-gpu==1.15
这篇关于Tensorflow 编译运行时间长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!