检查 Tensorflow 是否在 GPU 上运行 [英] Check whether Tensorflow is running on GPU

查看:85
本文介绍了检查 Tensorflow 是否在 GPU 上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了很多关于如何理解 Tensorflow 是否在 GPU 上运行的问题和指南",但我仍然很困惑.

I have read many questions and "guides" on how to understand if Tensorflow is running on GPU but I am still quite confused.

我截取了我的会话截图,我想了解发生了什么,以及 Tensorflow 是在 GPU 还是 CPU 上运行.

I have taken a screenshot of my session and I would like to understand what is going on, and if Tensorflow is running on GPU or CPU.

推荐答案

Roberto,试试这个

Roberto, try this

import tensorflow as tf
if tf.test.gpu_device_name():
    print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
    print("Please install GPU version of TF")

输出应该是

Default GPU Device: /device:GPU:0

GPU 0 是您的 GTX 860m

GPU 0 is your GTX 860m

这篇关于检查 Tensorflow 是否在 GPU 上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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