Besides, there are two issues that I think why your model could not work (not tested, just thoughts):


You split models on different devices, but the inputs  is not explicitly transferred to the device. Thus maybe the computing graph may experience unfound variables(possibly).


You may think the model parallelism as a serialized model:    y1 = model_part0 (input)  , y2 = model_part1(y1). Thus,  you could not write something like


with tf.device("/device:GPU:0"):
  x = ...
with tf.device("/device:GPU:1"):
  x = ...

with tf.device("/device:GPU:2"):
  x = f(x) # <- This will get confused

This may make the graph have duplicated variable. That’s why the assertion assert x.device.endswith("/GPU:1") failed.