Issue 1:
Seems to be an issue serializing a model returned from

tensorflow-gpu==1.11.0

keras==2.2.4

from keras.utils.training_utils import multi_gpu_model

..

..

gpu_model = multi_gpu_model(model,gpus=2)

gpu_model.compile(loss="binary_crossentropy", optimizer=opt,metrics=["accuracy"])

..

..

fit

..

print("[INFO] serializing model...")

gpu_model.save(config.MODEL_PATH, overwrite=True)

[INFO] serializing model...

Traceback (most recent call last):

File "train_alexnet.py", line 70, in

gpu_model.save(config.MODEL_PATH, overwrite=True)

File "C:\Users\ianfe\Envs\dl4cv\lib\site-packages\keras\engine\network.py", line 1090, in save

save_model(self, filepath, overwrite, include_optimizer)

File "C:\Users\ianfe\Envs\dl4cv\lib\site-packages\keras\engine\saving.py", line 382, in save_model

_serialize_model(model, f, include_optimizer)

File "C:\Users\ianfe\Envs\dl4cv\lib\site-packages\keras\engine\saving.py", line 83, in _serialize_model

model_config['config'] = model.get_config()

File "C:\Users\ianfe\Envs\dl4cv\lib\site-packages\keras\engine\network.py", line 931, in get_config

return copy.deepcopy(config)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 215, in _deepcopy_list

append(deepcopy(a, memo))

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 220, in _deepcopy_tuple

y = [deepcopy(a, memo) for a in x]

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 220, in

y = [deepcopy(a, memo) for a in x]

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 150, in deepcopy

y = copier(x, memo)

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 220, in _deepcopy_tuple

y = [deepcopy(a, memo) for a in x]

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 220, in

y = [deepcopy(a, memo) for a in x]

File "C:\Users\ianfe\Envs\dl4cv\lib\copy.py", line 169, in deepcopy

rv = reductor(4)

TypeError: can't pickle module objects

Issue 2:
Hey guys,

the new multi_gpu feature seems to have a bug. If you want to save the model you get an error like the one below. To reproduce just run the test multi_gpu_test_simple_model() with parallel_model.save("logs/model.h5") at the end.

def multi_gpu_test_simple_model():
print('####### test simple model')
num_samples = 1000
input_dim = 10
output_dim = 1
hidden_dim = 10
gpus = 4
epochs = 2
model = keras.models.Sequential()
model.add(keras.layers.Dense(hidden_dim,
input_shape=(input_dim,)))
model.add(keras.layers.Dense(output_dim))

x = np.random.random((num_samples, input_dim))
y = np.random.random((num_samples, output_dim))
parallel_model = multi_gpu_model(model, gpus=gpus)

parallel_model.compile(loss='mse', optimizer='rmsprop')
parallel_model.fit(x, y, epochs=epochs)

parallel_model.save("logs/model.h5")

multi_gpu_test_simple_model()

1000/1000 [==============================] - ETA: 0s - loss: 0.4537

Epoch 2/2

1000/1000 [==============================] - ETA: 0s - loss: 0.2939

Traceback (most recent call last):

File "steps_kt/test.py", line 43, in

multi_gpu_test_simple_model()

File "steps_kt/test.py", line 40, in multi_gpu_test_simple_model

parallel_model.save("logs/model.h5")

File "/home/y0052080/pyenv/lib/python3.6/site-packages/Keras-2.0.8-py3.6.egg/keras/engine/topology.py", line 2555, in save

File "/home/y0052080/pyenv/lib/python3.6/site-packages/Keras-2.0.8-py3.6.egg/keras/models.py", line 107, in save_model

File "/home/y0052080/pyenv/lib/python3.6/site-packages/Keras-2.0.8-py3.6.egg/keras/engine/topology.py", line 2396, in get_config

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 215, in _deepcopy_list

append(deepcopy(a, memo))

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 240, in _deepcopy_dict

y[deepcopy(key, memo)] = deepcopy(value, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 220, in _deepcopy_tuple

y = [deepcopy(a, memo) for a in x]

File "/cluster/tools/python3/lib/python3.6/copy.py", line 220, in

y = [deepcopy(a, memo) for a in x]

File "/cluster/tools/python3/lib/python3.6/copy.py", line 150, in deepcopy

y = copier(x, memo)

File "/cluster/tools/python3/lib/python3.6/copy.py", line 220, in _deepcopy_tuple

y = [deepcopy(a, memo) for a in x]

File "/cluster/tools/python3/lib/python3.6/copy.py", line 220, in

y = [deepcopy(a, memo) for a in x]

File "/cluster/tools/python3/lib/python3.6/copy.py", line 169, in deepcopy

rv = reductor(4)

TypeError: can't pickle module objects

Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on StackOverflow or join the Keras Slack channel and ask there instead of filing a GitHub issue.

Thank you!

[ x] Check that you are up-to-date with the master branch of Keras. You can update with:

pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

[ x] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.