怎么查看keras 或者 tensorflow 正在使用的GPU

from keras import backend as K
K.tensorflow_backend._get_available_gpus()



from tensorflow.python.client import device_lib
import tensorflow as tf

print(device_lib.list_local_devices())
print(tf.test.is_built_with_cuda())


import tensorflow as tf
print (tf.__version__)
if tf.test.gpu_device_name():
    print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
    print("Please install GPU version of TF")



原文地址:https://www.cnblogs.com/kpwong/p/13488711.html