先检查自己有没有gpu
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
输出类似这种
[
name: "/cpu:0"device_type: "CPU",
name: "/gpu:0"device_type: "GPU"
]
然后检查keras有没有在利用gpu
from keras import backend as K
K.tensorflow_backend._get_available_gpus()