Tensorflow警告:TensorFlow不是使用与计算能力8.6兼容的CUDA内核二进制文件构建的

mtb9vblg  于 8个月前  发布在  其他
关注(0)|答案(1)|浏览(96)

我有一个旧的英特尔酷睿i7 950 CPU,不支持AVX,一个新的NVIDIA RTX 3060 Ti GPU,计算能力8.6,和Windows 10操作系统。尽管默认的Tensorflow发行版需要AVX支持,但经过多次尝试和错误,我能够从this wheel安装Tensorflow,它是为没有AVX支持的CPU编译的。
为了做到这一点,我不得不降级到python 3.9,CUDA 11.7,cudnn 8.9.5和NumPy 1.22.4。
现在,当我在python中执行import tensorflow as tf时,我不会收到错误消息yay!但是,当我尝试该函数时:tf.config.list_physical_devices('GPU'),我得到:

W tensorflow/core/common_runtime/gpu/gpu_device.cc:1943] TensorFlow was not built with CUDA kernel binaries compatible with compute capability 8.6. CUDA kernels will be jit-compiled from PTX, which could take 30 minutes or longer.

查看下面的实际outpub:

C:\Users\Luca>python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.config.list_physical_devices('GPU')
2023-09-23 11:37:43.077533: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1943] TensorFlow was not built with CUDA kernel binaries compatible with compute capability 8.6. CUDA kernels will be jit-compiled from PTX, which could take 30 minutes or longer.
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
>>> tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

现在,我第一次运行它的时候,确实花了大约30分钟才得到结果,现在我每次运行它,我都得到相同的输出,但是结果是立即的(即,不用等30分钟就能得到[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]。请注意,当我在同一个会话中运行同一个函数时,我不会再次收到警告。
1.是什么原因导致警告每次都出现?
1.我该怎么摆脱它?

klr1opcd

klr1opcd1#

我不知道为什么我被降级,但通过谷歌搜索“抑制”一词,我找到了我的第二个问题的答案:
方法1(从这里学习):

import os

# Value for TF_CPP_MIN_LOG_LEVEL
# 0 = all messages are logged (default behavior)
# 1 = INFO messages are not printed
# 2 = INFO and WARNING messages are not printed
# 3 = INFO, WARNING, and ERROR messages are not printed

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

方法2(从here学习):

pip install silence_tensorflow

然后添加:

from silence_tensorflow import silence_tensorflow
silence_tensorflow()

我还是不知道我第一个问题的答案...
谢谢

相关问题