I have trained a network (using GPU) and now I want to run it (for inference) on a CPU. To do so, I use the following code which loads the meta graph and then the parameters of the network.
config = tf.ConfigProto(
device_count = {'GPU': 0}
)
sess = tf.Session(config=config)
meta_graph=".../graph-0207-190023.meta"
model=".../model.data-00000-of-00001"
new_saver = tf.train.import_meta_graph(meta_graph)
new_saver.restore(sess, model)
Problem is that since the graph has been defined for training, I have used some specific operations that do not run on CPU. For example "MaxBytesInUse" https://www.tensorflow.org/api_docs/python/tf/contrib/memory_stats/MaxBytesInUse which records the GPU activity.
Thats is why, when I try to run this code, I get the following error :
InvalidArgumentError: No OpKernel was registered to support Op 'MaxBytesInUse' with these attrs. Registered devices: [CPU], Registered kernels:
device='GPU'
[[Node: PeakMemoryTracker/MaxBytesInUse = MaxBytesInUse[_device="/device:GPU:0"]()]]
Is there a simple way to remove the specific GPU related operations and to run the graph on a CPU ?