我如何检查keras是否使用tensorflow的gpu版本?

我如何检查keras是否使用tensorflow的gpu版本?,第1张

我如何检查keras是否使用tensorflow的gpu版本

您正在使用GPU版本。您可以列出可用的tensorflow设备(也请检查此问题):

from tensorflow.python.client import device_libprint(device_lib.list_local_devices()) # list of DeviceAttributes

编辑:

使用tensorflow> =1.4时,您可以运行以下功能

import tensorflow as tftf.test.is_gpu_available() # True/False# Or only check for gpu's with cuda supporttf.test.is_gpu_available(cuda_only=True)

编辑2:

上面的功能在中已弃用

tensorflow > 2.1
。相反,您应该使用以下功能:

import tensorflow as tftf.config.list_physical_devices('GPU')

注意:

在您的情况下,cpu和gpu均可用,如果使用tensorflow的cpu版本,则不会列出gpu。在您的情况下,无需设置tensorflow设备(

withtf.device("..")
),tensorflow将自动选择您的GPU!

此外,您

sudo pip3 list
清楚地表明您正在使用tensorflow-gpu。如果您拥有tensoflow
cpu版本,则名称将类似于
tensorflow(1.1.0)

检查此问题以获取有关警告的信息。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5008655.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存