已解决To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags

已解决WARNING:tensorflow:From <stdin>1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.config.list_physical_devices(‘GPU’)~ instead.
2023-03-31 16:58:07.971004: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDMN) to use the following CPU instructions in performance-critical operations:
AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags




文章目录

  • 报错问题
  • 报错翻译
  • 报错原因
  • 解决方法
  • 千人全栈VIP答疑群联系博主帮忙解决报错



报错问题



粉丝群里面的一个小伙伴遇到问题跑来私信我,想用tensorflow,但是发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下所示:



报错信息内容截图如下所示


WARNING:tensorflow:From `<stdin>`1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.config.list_physical_devices('GPU')~ instead.
2023-03-31 16:58:07.971004: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDMN) to use the following CPU instructions in performance-critical operations:
AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags
False



报错翻译



报错信息内容翻译如下所示

警告:tensorflow:From(stdin)1:is_gpu_available(From tensorflow.python.framework.test_util)已弃用,并将在未来版本中删除。
更新说明:
请改用tf.config.list_physical_devices(‘GPU’)~。
2023-03-31 16:58:07.971004:I tensorflow/core/platform/cpu_feature_guard.cc:142]此tensorflow二进制文件使用oneAPI深度神经网络库(oneDMN)进行了优化,以在性能关键操作中使用以下cpu指令:
AVX-AVX2
要在其他操作中启用它们,请使用适当的编译器标志重新生成TensorFlow
错误





报错原因



报错原因

这个警告通常是由于使用了已经被弃用的函数或方法导致的。在这个警告中,is_gpu_available函数已经被弃用,将在将来的版本中被删除。

小伙伴们按下面的方法解决即可!!!





解决方法



这个警告通常是由于使用了已经被弃用的函数或方法导致的。在这个警告中,is_gpu_available函数已经被弃用,将在将来的版本中被删除。为了解决这个问题,你可以尝试以下方法:

  1. 如果你不需要使用GPU进行计算,可以忽略这个警告。你可以在代码中使用其他的函数或方法来检查你的TensorFlow是否支持GPU,例如:

    import tensorflow as tf
    print(tf.test.is_built_with_cuda())
    print(tf.test.is_gpu_available())
    

    这里使用了is_built_with_cuda()函数来检查TensorFlow是否编译了CUDA支持,使用is_gpu_available()函数来检查GPU是否可用。

  2. 如果你需要使用GPU进行计算,可以尝试升级你的TensorFlow版本。在较新的TensorFlow版本中,is_gpu_available()函数已经被替换为tf.config.list_physical_devices('GPU')函数。你可以使用以下代码来检查GPU是否可用:

    import tensorflow as tf
    print(tf.test.is_built_with_cuda())
    print(tf.config.list_physical_devices('GPU'))
    
  3. 如果你的TensorFlow版本较老,可以尝试升级到较新的版本来解决这个问题。

pytorch各版本和cuda版本对应关系,官网链接:https://pytorch.org/get-started/previous-versions/

注意:低版本的 pytorch 是否支持更高版本的 cuda;高版本的pytorch一般能兼容低版本cuda。例如:你需要 1.7.0 的 pytorch,那么 cuda 只能 11.0 及以下。官方推荐的cuda版本为10.2和11.3,这两种 cuda 支持大多数的 pytorch 版本。

PyTorch 版本CUDA 环境
0.4.1、1.2.0、1.4.0、1.5.0(1)、1.6.0、1.7.0(1)9.2
1.2.0、1.1.0、1.0.0(1)10.0
1.4.0、1.5.0(1)、1.6.0、1.7.0(1)10.1
1.5.0(1)、1.6.0、1.7.0(1)、1.8.0(1)、1.9.0、1.10.010.2
1.7.0(1)11.0
1.8.0(1)、1.9.0、1.10.011.1
1.8.0(1)、1.9.0、1.10.011.3

以上是此问题报错原因的解决方法,欢迎评论区留言讨论是否能解决,如果有用欢迎点赞收藏文章谢谢支持,博主才有动力持续记录遇到的问题!!!

千人全栈VIP答疑群联系博主帮忙解决报错

由于博主时间精力有限,每天私信人数太多,没办法每个粉丝都及时回复,所以优先回复VIP粉丝,可以通过订阅限时9.9付费专栏《100天精通Python从入门到就业》进入千人全栈VIP答疑群,获得优先解答机会(代码指导、远程服务),白嫖80G学习资料大礼包,专栏订阅地址:https://blog.csdn.net/yuan2019035055/category_11466020.html

  • 优点作者优先解答机会(代码指导、远程服务),群里大佬众多可以抱团取暖(大厂内推机会),此专栏文章是专门针对零基础和需要进阶提升的同学所准备的一套完整教学,从0到100的不断进阶深入,后续还有实战项目,轻松应对面试!

  • 专栏福利简历指导、招聘内推、每周送实体书、80G全栈学习视频、300本IT电子书:Python、Java、前端、大数据、数据库、算法、爬虫、数据分析、机器学习、面试题库等等

  • 注意:如果希望得到及时回复,和大佬们交流学习,订阅专栏后私信博主进千人VIP答疑群

免费资料获取,更多粉丝福利,关注下方公众号获取

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
扎眼的阳光的头像扎眼的阳光普通用户
上一篇 2023年5月28日
下一篇 2023年5月28日

相关推荐