这是运行脚本检查Tensorflow是否工作时收到的消息:

I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.so.8.0 locally
W tensorflow/core/platform/cpu_feature_guard.cc:95] 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:95] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:910] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero

我注意到它提到了SSE4.2和AVX,

什么是SSE4.2和AVX? 这些SSE4.2和AVX如何提高Tensorflow任务的CPU计算。 如何使用这两个库使Tensorflow编译?


当前回答

要隐藏这些警告,可以在实际代码之前执行此操作。

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

其他回答

我编译了一个小型的Mac Bash脚本(很容易移植到Linux)来检索所有CPU特性,并应用其中的一些来构建TF。我在TF大师和使用有点经常(一对夫妇在一个月)。

https://gist.github.com/venik/9ba962c8b301b0e21f99884cbd35082f

这些是SIMD矢量处理指令集。

对于许多任务来说,使用矢量指令更快;机器学习就是这样一项任务。

引用tensorflow安装文档:

为了与尽可能多的机器兼容,TensorFlow默认只在x86机器上使用SSE4.1 SIMD指令。大多数现代pc和mac都支持更高级的指令,所以如果您正在构建一个只在您自己的机器上运行的二进制文件,您可以在bazel构建命令中使用——copt=-march=native来启用这些指令。

使用SSE4.2和AVX编译TensorFlow,可以直接使用

Bazel build -config=mkl ——配置= "选择" ——科普特人=“3 = broadwell” ——科普特人= " o3 " / / tensorflow /工具/ pip_package: build_pip_package

来源: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/docker/Dockerfile.devel-cpu-mkl

我最近从源代码安装了它,下面是从源代码安装它所需的所有步骤,上面提到的说明是可用的。

其他答案已经描述了为什么会显示这些消息。我的回答给出了如何isinstall的一步一步,这可能会帮助那些像我一样在实际安装上挣扎的人。

安装巴泽尔

从它们的可用版本中下载它,例如0.5.2。 解压它,进入目录并配置它:bash ./compile.sh。 将可执行文件拷贝到/usr/local/bin: sudo cp ./output/bazel /usr/local/bin

安装Tensorflow

克隆tensorflow: git克隆https://github.com/tensorflow/tensorflow.git 进入克隆目录进行配置:./configure

它会提示你几个问题,以下是我对每个问题的建议回答,当然,你可以根据自己的喜好选择回答:

Using python library path: /usr/local/lib/python2.7/dist-packages
Do you wish to build TensorFlow with MKL support? [y/N] y
MKL support will be enabled for TensorFlow
Do you wish to download MKL LIB from the web? [Y/n] Y
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 
Do you wish to use jemalloc as the malloc implementation? [Y/n] n
jemalloc disabled
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
No Hadoop File System support will be enabled for TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] N
No XLA JIT support will be enabled for TensorFlow
Do you wish to build TensorFlow with VERBS support? [y/N] N
No VERBS support will be enabled for TensorFlow
Do you wish to build TensorFlow with OpenCL support? [y/N] N
No OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] N
No CUDA support will be enabled for TensorFlow

pip包。为了构建它,你必须描述你想要的指令(你知道,那些Tensorflow通知你的指令是缺失的)。

构建pip脚本:bazel Build -copt——copt=-mavx——copt=-mavx2——copt=-mfma——copt=-mfpmath=both——copt=-msse4.1——copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package

编译pip包:bazzel -bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

安装你刚刚构建的Tensorflow pip包:sudo pip Install /tmp/tensorflow_pkg/ Tensorflow -1.2.1-cp27-cp27mu-linux_x86_64.whl

现在你下次启动Tensorflow时,它不会再抱怨缺少指令了。

要隐藏这些警告,可以在实际代码之前执行此操作。

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