我刚刚启动了一个AWS P2实例来训练模型。然而,它似乎在使用CPU而不是GPU进行训练。我怎样才能强制它使用GPU而不是CPU进行训练呢?
$ nano ~/.keras/keras.json says this{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
我收到了一条消息“无法加载本地TensorFlow运行时。”
然后我更改了
$ nano ~/.keras/keras.json says this{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}
它在训练,但速度非常慢,似乎还是在使用CPU。
回答:
看来答案是添加一个gpus标志!
python cnn_homework_solution.py –gpus 0,1