方法1
import tensorflow as tf
if tf.test.gpu_device_name():
print(‘Default GPU Device: {}’.format(tf.test.gpu_device_name()))
else:
print(“Please install GPU version of TF”)
方法2
import tensorflow as tf
tf = tf.Session(config=tf.ConfigProto(log_device_placement=True))
tf.list_devices()
方法3
import tensorflow as tf
tf.test.gpu_device_name()
方法4
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
版权声明:本文为lwhsyit原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。