Tuesday, 28 February 2017

Change keras.json as per backend and connect it to gpu

1. On the remote machine or local machine, type python 

remote_user@remote_host$  cd ~/.keras/

It will open all .keras file. Now open all hidden files using ls -lha.



2. Open any editor like vi/vim/emacs and edit keras.json file

remote_user@remote_host$  nano keras.json

The default configuration file looks like this:
{"image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" }

Now Change as per your need, For theano backend:- in place of tf use th and as a backend put theano.

3. It will set it to theano backend. Lets check using the following:-
remote_user@remote_host$  python
>>> import keras
Using theano backend 

For Connectivity with Gpu, open .theanorc with cat ~/.theano.rc
change device=cpu to gpu
change cuda paths
GPU Connectivity will be enabled.