tensorflow是否调用了GPU

用如下代码可检测tensorflow的能使用设备情况:
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

注:

tensorflow版本和tensorflow-gpu版本两个版本有代差,而tensorflow默认选择版本高的版本来计算。

我的测试结果:

C:\Anaconda3\envs\tensorflow\python.exe D:/PycharmProjects/untitled/rmd.py
2019-01-04 22:13:36.406962: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-01-04 22:13:37.264907: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1356] Found device 0 with properties: 
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.8475
pciBusID: 0000:01:00.0
totalMemory: 8.00GiB freeMemory: 2.19GiB
2019-01-04 22:13:37.266146: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1435] Adding visible gpu devices: 0
2019-01-04 22:13:39.518693: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-01-04 22:13:39.518955: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:929]      0 
2019-01-04 22:13:39.519646: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:942] 0:   N 
2019-01-04 22:13:39.519948: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1053] Created TensorFlow device (/device:GPU:0 with 1889 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 573575045270182648
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 1981807820
locality {
  bus_id: 1
  links {
  }
}
incarnation: 1816188766871166043
physical_device_desc: "device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1"
]

Process finished with exit code 0
 

你可能感兴趣的:(python)