我在Windows 7 SP1 x64 Ultimate(Python 3.5.2|Anaconda自定义(64位))上安装了TensorFlow 1.0.0-rc2版本,使用:
pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0rc2-cp35-cp35m-win_amd64.whl
当我尝试从运行测试脚本时https://web.archive.org/web/20170214034751/https://www.tensorflow.org/get_started/os_setup#test_the_tensorflow_installation在Eclipse 4.5或控制台中:
import tensorflow as tf
print('TensorFlow version: {0}'.format(tf.__version__))
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
我收到一些错误消息:
TensorFlow version: 1.0.0-rc2
'Hello, TensorFlow!'
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflob
wcoreframeworkop_kernel.cc:943] OpKernel ('op: "BestSplits" device_type: "CPU"') for unknown op: BestSplits
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "CountExtremelyRandomStats" device_type: "CPU"') for unknown op: CountExtremelyRandomStats
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "FinishedNodes" device_type: "CPU"') for unknown op: FinishedNodes
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "GrowTree" device_type: "CPU"') for unknown op: GrowTree
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "ReinterpretStringToFloat" device_type: "CPU"') for unknown op: ReinterpretStringToFloat
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "SampleInputs" device_type: "CPU"') for unknown op: SampleInputs
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "ScatterAddNdim" device_type: "CPU"') for unknown op: ScatterAddNdim
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "TopNInsert" device_type: "CPU"') for unknown op: TopNInsert
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "TopNRemove" device_type: "CPU"') for unknown op: TopNRemove
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "TreePredictions" device_type: "CPU"') for unknown op: TreePredictions
E c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreframeworkop_kernel.cc:943] OpKernel ('op: "UpdateFertileSlots" device_type: "CPU"') for unknown op: UpdateFertileSlots
为什么?
TensorFlow 0.12.1(与pip install tensorflow==0.12.1
一起安装):没有这样的问题
TensorFlow version: 0.12.1
b'Hello, TensorFlow!'
安装今天的夜间构建(CPU版本):
pip install --upgrade http://ci.tensorflow.org/view/Nightly/job/nightly-win/85/DEVICE=cpu,OS=windows/artifact/cmake_build/tf_python/dist/tensorflow-1.0.0rc2-cp35-cp35m-win_amd64.whl
修复了问题(不再有“OpKernel ('op: ”BestSplits“ device_type: ”CPU“') for unknown op: BestSplits”
等)。
现在有一些SSE警告:
TensorFlow version: 1.0.0-rc2
b'Hello, TensorFlow!'
2017-02-15 19:56:22.688266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-02-15 19:56:22.688266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-02-15 19:56:22.689266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_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.
2017-02-15 19:56:22.689266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_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.
2017-02-15 19:56:22.689266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_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.
2017-02-15 19:56:22.689266: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_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.
在这种情况下,您可以尝试如何使用SSE4.2和AVX指令编译Tensorflow?
TensorFlow 1.0.0几天前发布。然而,它也有同样的问题。最近的夜间构建有不同的警告:
sess = tf.Session()
2017-02-17 13:01:59.790943: W c:tf_jenkinshomeworkspacenightly-windevicecpuoswindowstensorflowcoreplatformcpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
仅供参考:Tensorflow macOS二进制文件,使用SSE4.1、SSE4.2和AVX优化编译。
要隐藏警告/错误,可以使用os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
,例如:
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
print('TensorFlow version: {0}'.format(tf.__version__))
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
TF_CPP_MIN_LOG_LEVEL
:
0
:显示所有日志(这是默认设置)1
:过滤掉INFO
日志2
:额外过滤掉WARNING
日志3
:额外过滤掉ERROR
日志
参考上面的建议,我认为做两个步骤是有帮助的:
第一,升级tensorflow:
pip install --upgrade tensorflow==1.1.0rc1
然后,错误日志变为警告日志:
W c:tf_jenkinshomeworkspacerelease-windevicecpuoswindowstensorflowcoreplatformcpu_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.
第二,您可以在2级抑制警告过滤器。
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
我认为它在不过滤"错误"日志的情况下运行良好。
您可以在级别2抑制警告过滤器。这对我在虚拟安装中使用TensorFlow 1.0.1起到了作用。
os.environment['TF_CPP_MIN_LOG_LEVEL']='2'
对补充的答案感到抱歉,但我不值得评论。
该问题在1.1.0rc0及更高版本中似乎已修复。
查找tensorflow的最新版本:
pip search --version tensorflow
升级tensorflow:
pip install --upgrade tensorflow==1.1.0rc1