Tensorflow Warning: The TensorFlow library wasn’t compiled to use SSE,SSE2,SSE3,SSE4.1 instructions,but these are available on your machine and could speed up CPU computations.

在使用tensorflow时,会一段巨长的warning,如下图所示:

总结来说,就是电脑上的tensorflow不能编译SSE, SSE2, SSE3, SSE4.1这些指令集, 但是机器上是有这些指令集的,并且使用这些指令会加快CPU的运行速度.

然而当前的TensorFlow在编译时并没有用到这些指令集,需要手动编译才能加入这些指令集. 所以tensorflow的运行速度会比较慢,不过程序仍然是可以运行的.

原因

出现这种warning的原因是当前使用的tensorflow是采用pip命令安装的,不是从源码编译安装的. 安装的Tensorflow中缺少了对应的模块,需要编译安装。
顺便提一句,当我们使用GPU时并不需要用到CPU,所以这些warning可以忽略.

解决

查阅网上的资料,发现要想消除这个warning有2种方法:

  1. 在代码前加上以下指令,修改警告信息的显示级别,使得运行不出现warning提示:
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf

为什么加了这句指令就不会出现Warning提示了呢? 因为修改了信息的显示级别:

# 1級
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='1'    # 所有信息都显示
# 2級
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'     # 只显示 warning 和 Error
# 3級
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='3'     # 只显示 Error
  1. 重新编译安装tensorflow,在编译的时候使用这些指令集.
    具体的步骤在其他博客中有写到,这里只规整一下:

Step1 卸载已经安装的tensorflow
Step2 克隆tensorflow仓库,使用下面的命令会在当前文件夹中创建一个名为“tensorflow”的文件夹,下载的文件都存在里面.

git clone --recurse-submodules https://github.com/tensorflow/tensorflow

Step3 安装bazel,在编译安装tensorflow的时候要用到bazel工具. 按照官网指导输入命令.
Step4 开始编译TensorFlow
a. configure

cd tensorflow
./configure

b. bazel build
#CPU

bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

c.生成whl文件

bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

d. 安装编译好的包

pip install /tmp/tensorflow_pkg/tensorflow-{version}-none-any.whl

e. 验证TensorFlow是否安装成功

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

测试成功即可,我还没有试验是否可行,先记下来,找合适时间实践.

具体的过程在参考资料[1]中有着详细的讲解.
参考资料:
[1] TensorFlow CPU环境 SSE/AVX/FMA 指令集编译
sess.run()出现如下Warning

[2] TensorFlow問題“The TensorFlow library wasn’t compiled to use SSE instructions, but these are available on your machine and could speed up CPU conputations

Warning: The TensorFlow library wasn't compiled to use SSE,SSE2,SSE3,SSE4.1 instructions相关推荐

  1. The TensorFlow library wasn‘t compiled to use SSE instructions, but these are available on your mach

    pycharm python中遇到The TensorFlow library wasn't compiled to use SSE instructions, but these are avail ...

  2. 运行TensorFlow出现The TensorFlow library wasn‘t compiled to use FMA instructions)代码

    TensorFlow出错点(2)(The TensorFlow library wasn't compiled to use FMA instructions) 错误提示: 解决措施: 错误提示: 摘 ...

  3. Tensorflow警告:our CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

    使用TensorFlow模块时,弹出错误Your CPU supports instructions that this TensorFlow binary was not compiled to u ...

  4. 去除警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

    去除警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 文章 ...

  5. 成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2(二)

    成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2(二) ...

  6. 成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

    成功解决Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 目录 ...

  7. 彻底解决“Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA”警告

    问题描述 在使用TensorFlow时,总是提醒"Your CPU supports instructions that this TensorFlow binary was not com ...

  8. tensorflow:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

    ps:这跳出的是一个cpu警告,但我用的是gpu啊!!即使我安装合适版本的(编译过的)tensorflow来满足我cpu的AVX2扩展,也还是没对我的运行速度有太大提高(猜测),所以如果你是使用gpu ...

  9. 警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA(亲测)

    警告:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 转载:h ...

最新文章

  1. 机器人图形变变变_幼儿园大班数学活动《图形变变变》PPT课件教案下载 - 快思幼教网...
  2. mysql 手机号 字段_2021-01-06:mysql中,我存十亿个手机号码,考虑存储空间和查询效率,用什么类型的字段去存?...
  3. SparkSQL之操作Hive
  4. java的安装和配置
  5. 互联网大佬马老师于昨日教师节正式卸任,让位现任CEO张勇;华为发布新一代CloudLink视讯解决方案,普惠4K+AI;联通……...
  6. 高颜值网易云音乐第三方播放器 YesPlayMusic Mac中文版 支持m1
  7. 如何解决系统补丁(KB971092)重复安装问题
  8. Windows的一些网络设置
  9. Mybatis分页查询(通过SQL分页实现)
  10. centos7图形化分区和ks文件分区的配置
  11. 微信网页版扫码登录是如何实现的?
  12. 卫生保健所短信群发模板:预约挂号、就诊提醒、检查结果通知
  13. Matlab图形窗口大小的控制 ,plot窗口大小,figure大小,axis设置,实用
  14. 一种基于加密域的数字图像水印算法的设计与实现(附Matlab源码)
  15. 如何将CVAT的docker镜像上传到华为云镜像中心SWR
  16. zsh 及 oh-my-zsh 使用
  17. scrapy爬虫 出现10054错误 远程主机强迫关闭了一个现有的连接
  18. 3.牛顿迭代法求解方程的根
  19. 基于电力大数据的空气污染预测
  20. typora 分割线_最全Typora语法大全(含详细数学表达式及流程图)

热门文章

  1. 科大讯飞语音识别 支持多语音欢迎指点
  2. 家电智能化转型之下 长虹在挖什么“坑”?
  3. php for 每次增加2,php – 为什么foreach会将refcount增加2而不是1?
  4. net472无法建立到信任_是否还会信任,那个曾经背叛过自己的人
  5. Vue-动态组件和插槽
  6. vue+sortable实现表格拖拽
  7. mongodb自定义字段_MongoDB哈希分片
  8. mysql禁止远程连接
  9. idea2020版Maven依赖成功导入但仍然报错找不到包解决
  10. Element-UI中el-input输入值不显示