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

转自https://blog.csdn.net/Fourierrr_/article/details/79749899

deepin下使用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点这里下载。其他操作系统可以点这里找到对应的版本。deepin Linux就可以选择对应的Ubuntu 16.04版本的来安装。

我用的deepin15.7,python3.5,所以选择如下图:

在这里插入图片描述

然后cd到下载目录下:

sudo pip install tensorflow-1.11.0-cp35-cp35m-linux_x86_64.whl

执行安装。

成功安装后,再次运行TensorFlow就不会报错啦~

猜你喜欢

转载自blog.csdn.net/FK103/article/details/84312571
今日推荐