Google colab not using GPU, if keras backend is theano

1.1k views Asked by At

I suspect google colab is not using GPU, if I use theano as backend with Keras. Same code trains at the rate of ~4min per epoc, if back end is Tensorflow, but takes 7 hours per epoc with theano as back end. I did following steps to modify keras configuration

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

keras.json for theano looks like

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

keras.json for tensorflow looks like

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

With theano backend same code timing looks like

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

But with tensorflow, it takes 4-5 min

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

Any help?

0

There are 0 answers