tensorflow.test.is_gpu_available()
>>> import tensorflow as tf
>>> tensorflow.test.is_gpu_available()
2021-02-04 21:06:25.317017: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2070 computeCapability: 7.5
coreClock: 1.44GHz coreCount: 36 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
......
2021-02-04 21:06:25.325876: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-02-04 21:06:25.328164: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-02-04 21:06:25.328511: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267] 0
2021-02-04 21:06:25.329061: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0: N
2021-02-04 21:06:25.329462: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/device:GPU:0 with 6637 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)
2021-02-04 21:06:25.330054: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
True
这里返回True即是可用,如果返回了False就是不可用了
文章评论