如何检查keras tensorflow后端是GPU还是CPU版本? [英] How to check if keras tensorflow backend is GPU or CPU version?

查看:954
本文介绍了如何检查keras tensorflow后端是GPU还是CPU版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解在安装tensorflow时,您可以安装GPU或CPU版本.如何检查安装了哪一个(我使用linux).

I understand that when installing tensorflow, you either install the GPU or CPU version. How can I check which one is installed (I use linux).

如果安装了GPU版本,如果GPU不可用,它将在CPU上自动运行还是会引发错误?如果GPU可用,是否需要设置一个特定的字段或值以确保它在GPU上运行?

If the GPU version is installed, would it be automatically running on CPU if GPU is unavailable or would it throw an error? And if GPU is available, is there a specific field or value you need to set to make sure it's running on GPU?

推荐答案

还可以使用Keras后端功能进行检查:

Also you can check using Keras backend function:

from keras import backend as K
K.tensorflow_backend._get_available_gpus()

我在Keras(2.1.1)上进行了测试

I test this on Keras (2.1.1)

这篇关于如何检查keras tensorflow后端是GPU还是CPU版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆