以下是from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 8087623604945614369
]
以下是pip list | grep tensorflow
的输出:
tensorflow-gpu (1.4.0)
tensorflow-tensorboard (0.4.0rc3)
我可以确认我已经在我的机器上安装了cuda 8.0和cudnn,nvidia-smi
的输出显示了GPU以及其他详细信息。有人可以帮我理解为什么print(device_lib.list_local_devices())
的输出没有显示GPU?rr
试过这个简单的张量流示例:
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
错误:
Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]