解决Tensorflow 使用时cpu编译不支持警告

原文地址:https://blog.csdn.net/Fourierrr_/article/details/79749899

使用TensorFlow模块时,弹出错误Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

原因是下载TensorFlow的版本不支持cpu的AVX2编译。

可能是因为安装时使用的pip install tensorflow ,这样默认会下载X86_64的SIMD版本。

有两种解决办法:

1.忽略这个警告,不看它!

import os  
os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # 这是默认的显示等级,显示所有信息  
os.environ["TF_CPP_MIN_LOG_LEVEL"]='2' # 只显示 warning 和 Error   
os.environ["TF_CPP_MIN_LOG_LEVEL"]='3' # 只显示 Error

我们用第二个就可以了。

2.彻底解决,换成支持cpu用AVX2编译的TensorFlow版本。

首先,卸载原来版本的TensorFlow

pip uninstall tensorflow

完成后可以用pip list查看一下所有库,检查是否成功卸载。

然后去github下载正确的tf版本,Windows点这里下载。其他操作系统可以点这里找到对应的版本。

博主用的win10,python3.6,所以选择如下图:

对应的path在上边的找到对应的.whl下载即可。

然后安装:

pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl

猜你喜欢

转载自blog.csdn.net/cn_yaojin/article/details/83416651
今日推荐