【发布时间】:2017-04-11 15:27:54
【问题描述】:
我正在使用 tensorflow(不支持 GPU),与预期相比,我发现性能受到了相当大的影响。所以,我认为是时候注意这些警告了:
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
我看到有些人声称,按照这些说明进行构建,他们的速度提高了近 10 倍。
不过,我发现的有关执行此操作的说明似乎与旧版本的 TF (v
按照此处的说明在 Mac OSX 上安装 python3:https://www.tensorflow.org/install/install_sources 并选择“否”以获得 CUDA 支持。
并使用 bazel 命令:
bazel build --linkopt='-lrt' -c opt --copt=-march=native --copt=-mavx --copt=-msse4.2 --copt=-msse4.1 //tensorflow/tools/pip_package:build_pip_package
但是,这会导致许多页面的警告/错误...主要是以下形式:
target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': Use SavedModel Builder instead.
和
external/protobuf/python/google/protobuf/pyext/message_factory.cc:78:28: warning: ISO C++11 does not allow conversion from string literal to 'char *' [-Wwritable-strings]
编辑
我会注意到,我只看到了从源头构建速度的微小提高。
【问题讨论】:
-
关于说明,官方文档正在关注最新的更新。该命令是文档
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package中指定的命令。如果您在配置时将 SIMD 指令定义为默认值,例如-march=native你不需要将其他人指定为msse4.2、mavx等,因为它应该在你的 CPU 架构中使用可用的优化进行编译。如果您确实设置了特定说明,但您需要在构建时定义相应的标志。 -
嗨 @AdrianoCarmezim,运行基本的 bazel 命令
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package会为我抛出同样的错误 -
你提到的是警告,不会阻止你构建 TF,是否有错误日志被发出?
-
安装后我无法导入 tensorflow,但我现在看到这是一个单独的问题。你是对的,只使用
-march=native从源代码构建正确优化了安装。 -
很高兴它现在正在工作。对于导入问题,如果您仍然面临它,请随时在 Github 上打开一个问题,或者让我知道我是否可以提供更多帮助:) 如果其他人碰巧遇到同样的情况,我会留下答案。
标签: tensorflow bazel protobuf-c