我最近安装了tensorflow (Windows CPU版本),收到了以下消息:

成功安装tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc2

然后当我试图逃跑的时候

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
sess.run(hello)
'Hello, TensorFlow!'
a = tf.constant(10)
b = tf.constant(32)
sess.run(a + b)
42
sess.close()

(我是在https://github.com/tensorflow/tensorflow上找到的)

我收到了以下信息:

2017-11-02 01:56:21.698935: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard。cc:137]你的CPU支持这个TensorFlow二进制文件没有被编译使用的指令:AVX AVX2

但当我逃跑时

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

它正常运行并输出Hello, TensorFlow!,这表明安装确实是成功的,但还有一些地方是错误的。

你知道问题是什么以及如何解决它吗?


当前回答

对我有用的是这个图书馆https://pypi.org/project/silence-tensorflow/

安装这个库,并按照页面上的指示,它的工作就像一个魅力!

其他回答

如果你使用的是TensorFlow的pip版本,这意味着它已经编译好了,你只是在安装它。基本上你安装了TensorFlow-GPU,但是当你从存储库下载它并试图构建它时,你应该在CPU AVX支持下构建它。如果忽略它,每次在CPU上运行时都会收到警告。你也可以看看那些。

使用SSE4.2和AVX编译Tensorflow的正确方法

AVX Cpu在tensorflow中的支持是什么

对于Windows(感谢所有者f040225),请访问这里:https://github.com/fo40225/tensorflow-windows-wheel,根据“tf + python + cpu_instruction_extension”的组合获取您的环境的url。然后使用这个cmd来安装:

pip install --ignore-installed --upgrade "URL"

如果你遇到“File is not a zip File”错误,下载.whl文件到你的本地计算机,并使用这个cmd来安装:

pip install --ignore-installed --upgrade /path/target.whl

我发现解决这个问题最简单的方法是卸载所有东西,然后安装特定版本的tensorflow-gpu:

卸载tensorflow:

    pip uninstall tensorflow

卸载tensorflow-gpu:(确保运行这个,即使你不确定你是否安装了它)

    pip uninstall tensorflow-gpu

安装特定的tensorflow-gpu版本:

    pip install tensorflow-gpu==2.0.0
    pip install tensorflow_hub
    pip install tensorflow_datasets

你可以通过在python文件中添加以下代码来检查是否有效:

from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np

import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds

print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub Version: ", hub.__version__)
print("GPU is", "available" if tf.config.experimental.list_physical_devices("GPU") else "NOT AVAILABLE")

运行文件,然后输出如下所示:

Version:  2.0.0
Eager mode:  True
Hub Version:  0.7.0
GPU is available

希望这能有所帮助

GPU CPU优化

即使你有GPU并使用它进行训练和推理,通过从源代码安装TensorFlow也可以获得性能上的提升。原因是有些TF操作只有CPU实现,不能在GPU上运行。

此外,还有一些性能增强技巧可以很好地利用CPU。TensorFlow的性能指南建议如下:

将输入管道操作放在CPU上可以显著提高性能。利用CPU作为输入管道,可以让GPU专注于训练。

为了获得最佳性能,你应该编写代码来利用CPU和GPU协同工作,如果你有GPU的话,不要把所有的代码都转储到GPU上。 为你的CPU优化你的TensorFlow二进制文件可以节省几个小时的运行时间,你必须这样做一次。

对我有用的是这个图书馆https://pypi.org/project/silence-tensorflow/

安装这个库,并按照页面上的指示,它的工作就像一个魅力!