I am using
Tensorflow 2.0
After following the migration guide from Tensorflow 1.14 to Tensorflow 2.0, I was importing all the modules from tensorflow.keras
instead of just keras
. But the following commands gives the Attribute error -
from tensorflow.keras import backend as K
K.tensorflow_backend._get_available_gpus()
Output: AttributeError: module 'tensorflow_core.keras.backend' has no attribute 'tensorflow_backend'
But just importing the backend from keras
works
from keras import backend as K
K.tensorflow_backend._get_available_gpus()
Output:['/job:localhost/replica:0/task:0/device:GPU:0']
I want to know if keras is using GPU, and I don't understand the interaction of 'keras' and 'tf.keras'. My entire neural network is built on layers imported from tensorflow.keras
Edit: I am using a customised ImageDataGenerator function, this is how I am importing it -
from keras.preprocessing.image import ImageDataGenerator
instead of from tensorflow.keras.preprocessing.image import ImageDataGenerator
. That's why I want to check if Keras is also running on GPU. Do I need to ensure this? If yes, how?