Reputation: 21
I was trying to figure out how to create a model with Keras. To help me, I'm making use of plot_model
to visualize the model as I assemble it. The program is just assembling a sequential model and exporting it using plot_model
.
Everything was working fine until I tried to add a Batch Normalization (BN) layer to the model.
The program suddenly attempts to add a GPU device and freezes. I'm forced to close the program through Task Manager
I'm running this in Windows 10. Python version 3.6. Tensorflow-gpu version 1.12.0. Keras version 2.2.4
I thought I had imported from the wrong library, so I tried referencing it directly. It didn't change anything. I've tried consulting different implementations of BN layers and they all seem to implement them the same way I do without a problem.
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, BatchNormalization, LeakyReLU, Activation
import keras
import os
encoder = Sequential()
encoder.add(Conv2D(64, (7,7),strides=(2,2), input_shape=(256, 256,3)))
encoder.add(keras.layers.BatchNormalization())
encoder.add(LeakyReLU())
encoder.add(Conv2D(64, 3, strides=3, padding='same'))
from keras.utils import plot_model
plot_model(encoder, to_file='model.png', show_shapes=True)
print ('done')
When I run the program, it hangs on this output: I:tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
and never outputs the 'done' message. The plot_model
image doesn't export either.
The above message is also very unusual, as it doesn't show up when any of the other layers are added to the encoder.
Upvotes: 1
Views: 1403
Reputation: 15003
Try downgrading TensorFlow to 1.9 version.
If this does not work, uninstall Keras (and its applications and preprocessing).
Then, in your code, modify all the imports from keras.models to tensorflow.keras.models; in other words, every import you make, do it via tensorflow.
Upvotes: 1