查看是否有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: 10641965056
locality {
  bus_id: 1
  links {
  }
}
incarnation: 7203835317376623910
physical_device_desc: "device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7"
GitHub 加速计划 / te / tensorflow
184.54 K
74.12 K
下载
一个面向所有人的开源机器学习框架
最近提交(Master分支:1 个月前 )
a49e66f2 PiperOrigin-RevId: 663726708 1 个月前
91dac11a This test overrides disabled_backends, dropping the default value in the process. PiperOrigin-RevId: 663711155 1 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐