谷歌colab没有使用GPU,如果keras后端是theano

时间:2018-04-15 04:57:42

标签: tensorflow keras theano google-colaboratory theano-cuda

我怀疑google colab没有使用GPU,如果我使用theano作为Keras的后端。如果后端是Tensorflow,则相同的代码以每个epoc约4分钟的速率训练,但是每个epoc需要7个小时,其中theano作为后端。我按照以下步骤修改了keras配置

!cp .keras/keras.json .keras/keras.json.tf
!cp drive/MachineLearning/kerasJson/keras.json .keras/keras.json
!cat .keras/keras.json

keano.json for theano看起来像

{
    "floatx": "float32",
    "epsilon": 1e-07,
    "backend": "theano",
    "image_dim_ordering": "th",
    "image_data_format": "channels_first"
}

keras.json for tensorflow看起来像

{
    "floatx": "float32",
    "epsilon": 1e-07,
    "backend": "tensorflow",
    "image_data_format": "channels_last"
}

使用theano后端,相同的代码时序看起来像

drive/MachineLearning/data/NLP/keras_spell_e2.h5

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:268: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<generator..., steps_per_epoch=100, epochs=500, verbose=1, callbacks=[<__main__..., validation_data=<generator..., validation_steps=10, class_weight=None, workers=1, initial_epoch=0, use_multiprocessing=False, max_queue_size=10)`

Epoch 1/500
  2/100 [..............................] - ETA: 6:58:52 - loss: 0.5325 - acc: 0.4895

但是使用张量流,需要4-5分钟

drive/MachineLearning/data/NLP/keras_spell_e2.h5

/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:268: UserWarning: Update your `fit_generator` call to the Keras 2 API: `fit_generator(<generator..., steps_per_epoch=100, epochs=500, verbose=1, callbacks=[<__main__..., validation_data=<generator..., validation_steps=10, class_weight=None, workers=1, initial_epoch=0, use_multiprocessing=False, max_queue_size=10)`

Epoch 1/500
 14/100 [===>..........................] - ETA: 3:45 - loss: 0.5161 - acc: 0.4998

任何帮助?

0 个答案:

没有答案