tensorflow安装CPU指令集(AVX2)警告解决方案

在macOS上安装TensorFlow(CPU版)后出现AVX2警告,警告指出CPU支持AVX但未充分利用。该警告源于TensorFlow默认构建时不启用CPU扩展。为充分利用CPU,需要从源码重新安装TensorFlow,启用AVX和FMA扩展。如果拥有GPU,可以直接忽略警告。否则,可以参考GitHub仓库下载对应版本的预编译pip包进行安装。
摘要由CSDN通过智能技术生成

问题原因

在macOS通过pip3 install 安装tensorflow(CPU版)后,运行示例代码

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

运行之后可以正常输出

“Hello, TensorFlow!”

但是有一个警告警告提示:

 I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

在Stack Overflow上面关于这个问题有一个详细的解答

大致翻译一下高赞答案:

Modern CPUs provide a lot of low-level instructions, besides the usual arithmetic and logic, known as extensions, e.g. SSE2, SSE4, AVX, etc. From the Wikipedia:

Advanced Vector Extensions (AVX) are extensions to the x86 instruction set architecture for microprocessors from Intel and AMD pro

评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值