Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

执行Python程序时,TensorFlow会报CPU支持AVX扩展但当前版本无法编译使用的警告。博客给出了解决办法,分别针对GPU版本和CPU版本(pip install tensorflow)的安装情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在执行python程序的时候,报Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA的警告。大概意思是:你的CPU支持AVX扩展,但是你安装的TensorFlow版本无法编译使用。

在这里插入图片描述

解决方法:

如果安装的是GPU版本
如果你有一个GPU,你不应该关心AVX的支持,因为大多数昂贵的操作将被分派到一个GPU设备上(除非明确地设置)。在这种情况下,您可以简单地忽略此警告: 

import os 
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
如果安装的是CPU版本(pip install tensorflow)
1.在代码中加入如下代码,忽略警告: 

import os 
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' 
2.编译TensorFlow源码 

    如果您没有GPU并且希望尽可能多地利用CPU,那么如果您的CPU支持AVX,AVX2和FMA,则应该从针对CPU优化的源构建tensorflow。在这个问题中已经讨论过这个问题,也是这个GitHub问题。 Tensorflow使用称为bazel的ad-hoc构建系统,构建它并不是那么简单,但肯定是可行的。在此之后,不仅警告消失,tensorflow性能也应该改善。

更多学习资讯,学习源码,请在耶宇星球领取

更多学习资讯,学习源码,请在耶宇星球领取
Skipping registering GPU devices... 2025-07-26 19:41:36.404421: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA 2025-07-26 19:41:36.434980: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2000000000 Hz 2025-07-26 19:41:36.441018: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f2764000b60 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2025-07-26 19:41:36.441046: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2025-07-26 19:41:36.442874: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix: 2025-07-26 19:41:36.442890: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] WARNING:tensorflow:From /root/Python/conda_lit/kind/lib/python3.6/site-packages/tf_slim/layers/layers.py:1089: Layer.apply (from tensorflow.python.keras.engine.base_layer_v1) is deprecated and will be removed in a future version. Instructions for updating: Please use `layer.__call__` method instead. loaded ./checkpoint/decom_net_train/model.ckpt loaded ./checkpoint/illumination_adjust_net_train/model.ckpt No restoration pre model! (480, 640, 3) (680, 720, 3) (415, 370, 3) Traceback (most recent call last): File "evaluate.py", line 73, in <module> eval_low_im = load_images(eval_low_data_name[idx]) File "/root/Python/KinD-master/KinD-master/utils.py", line 63, in load_images im = Image.open(file) File "/root/Python/conda_lit/kind/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open fp = builtins.open(filename, "rb") IsADirectoryError: [Errno 21] Is a directory: './test/results'
最新发布
07-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北顾丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值