I am using the Keras Subclassing API to create a custom model. I tried to parallelize my model using:
parallel_model = keras.utils.multi_gpu_model(subclassed_model, gpus=num_gpus)
However I encountered the following error:
line 203, in multi_gpu_model
for i in range(len(model.outputs)):
TypeError: object of type 'NoneType' has no len()
After, reading the docs in more detail, I noticed the following:
In subclassed models, the model's topology is defined as Python code(rather than as a static graph of layers). That means the model's topology cannot be inspected or serialized. As a result, the following methods and attributes are not available for subclassed models:
model.inputsandmodel.outputs.
So how can I train subclassed models on multiple GPUs? Have in mind that I am only interested in data parallelization.