查看是否有GPU
import tensorflow as tf
gpu_device_name = tf.test.gpu_device_name()
print(gpu_device_name)
输出
/device:GPU:0
- GPU是否可用
# 返回True或者False
tf.test.is_gpu_available()
from tensorflow.python.client import device_lib
# 列出所有的本地机器设备
local_device_protos = device_lib.list_local_devices()
# 打印
# print(local_device_protos)
# 只打印GPU设备
[print(x) for x in local_device_protos if x.device_type == 'GPU']
输出如下
name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 9292310119
locality {
bus_id: 1
links {
}
}
incarnation: 1788714284653564190
physical_device_desc: "device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1"
参考网址: