查看GPU是否可用
作者:互联网
tf.config:GPU 的使用与分配(转载) - 三年一梦 - 博客园 (cnblogs.com) import tensorflow as tf version = tf.__version__ gpu_ok = tf.test.is_gpu_available() # tf.config.list_physical_devices('GPU') # 也可以 print("tf version:", version, "\nuse GPU", gpu_ok) print(tf.test.is_built_with_cuda()) gpus = tf.config.list_physical_devices(device_type='GPU') # [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] cpus = tf.config.list_physical_devices(device_type='CPU') # [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')] print(gpus) print(cpus)
标签:查看,可用,print,device,tf,GPU,type,physical 来源: https://blog.csdn.net/Silentli20/article/details/116929721