【问题标题】:Tensorflow installation using SSE instructions with pip使用带有 pip 的 SSE 指令安装 TensorFlow
【发布时间】:2017-07-09 03:42:51
【问题描述】:

我使用here 提供的默认说明成功地在 ubuntu 16.04 上安装了 cpu only tensorflow。说明建议使用 virtualenv 和 pip,所以我没有从源代码构建。按照这些说明进行安装没有问题。

我使用同一页面上further down 提供的说明验证了我的安装,当程序成功运行时,它会输出以下警告。

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 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.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.
Hello, TensorFlow!

我查看的所有 stackoverflow 页面仅针对使用 bazel 从源代码构建的人,但似乎不适用于使用 pip 的人。

如何根据 SSE 说明重新编译或更新我的安装?

【问题讨论】:

  • 这可能是你有一些混合环境的问题,过去我确实使用源代码在 ubuntu 16.04 上安装 tensorflow,但由于 v.0.11 简单的 pip 安装工作正常
  • 我已经编译了 tensorflow 以使用 SSE 指令。您可以从github.com/lakshayg/tensorflow-build 下载预编译的二进制文件。

标签: python tensorflow pip virtualenv sse


【解决方案1】:

这些只是警告。按照这个link,在导入TensorFlow之前添加这行,

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf

我也有同样的问题,但是建议的链接解决了我的问题。

也可以看看这个answer,这将有助于了解更多关于SSE信息以及不同类型的日志指标。

【讨论】:

    【解决方案2】:
    bazel build --linkopt='-lrt' -c opt --copt=-mavx --copt=-msse4.2 --copt=-msse4.1 --copt=-msse3-k //tensorflow/tools/pip_package:build_pip_package
    

    如果以上解决了您的问题,请在How do I resolve these tensorflow warnings? 上投票Christian Frei's 回答

    【讨论】:

      【解决方案3】:

      您必须使用bazel 和--config=opt 选项来构建为您的架构定制的轮子,然后使用pip 安装生成的轮子。

      我计划偶尔将 2014 MacBook + Xeon V3 优化版本上传到https://github.com/yaroslavvb/tensorflow-community-wheels

      安装 Bazel 后,为您的 pip 命令制作轮子大致如下

      ./configure
      
      export LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH"
      export flags="--config=opt --config=cuda -k"
      
      bazel build $flags -k //tensorflow/tools/pip_package:build_pip_package
      bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
      

      然后将轮子放入/tmp/tensorflow_pkg

      【讨论】:

      • 嗯,您介意告诉我应该在安装的哪个步骤执行此操作吗?我只是按照 tensorflow 教程中有关 virtualenv 的说明进行操作,不知道应该在哪里执行此配置步骤
      • 您需要按照说明从源代码构建
      • 我不太愿意处理从源代码构建可能带来的任何问题。我现在将其作为问题放在 tensorflow github 上并处理警告编辑:按下输入期待新段落
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-25
      相关资源
      最近更新 更多