Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuilding model during load gives error for multi GPU model #44

Open
suvojit-0x55aa opened this issue Aug 25, 2019 · 1 comment
Open

Comments

@suvojit-0x55aa
Copy link

self.model, inputs_mask = self.build_pconv_unet(train_bn)

Rebuilding the model without the init options gives error when training on multi GPU.
Error traceback:

Traceback (most recent call last):
  File "train_pconvunet.py", line 270, in <module>
    model.load(args.checkpoint)
  File "/home/ubuntu/image-inpainting/libs/pconv_model.py", line 307, in load
    self.model.load_weights(filepath)
  File "/home/ubuntu/image-inpainting/env/lib/python3.6/site-packages/keras/engine/topology.py", line 2667, in load_weights
    f, self.layers, reshape=reshape)
  File "/home/ubuntu/image-inpainting/env/lib/python3.6/site-packages/keras/engine/topology.py", line 3365, in load_weights_from_hdf5_group
    str(len(filtered_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 1 layers into a model with 31 layers.

Commenting the rebuilding and compilation statements in the load function works however.

@ghost
Copy link

ghost commented Aug 28, 2019

This is because your saved model weights from multi GPU model, and push it into single GPU model.
There are some solutions.
1. Go to Pconv_model.py, and change "load model" function to build multi GPU model with the same number of GPU, which your model trained on.
2. Save your weights for single GPUs. Make sure your multi GPU model with model.summary() and model.layer[index
]

In my private opinion,
I prefer the second, because sometimes the number of GPUs for training is different for ones for inference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant