Hi, thanks for sharing this. I was wondering if it's possible to load the model on cpu and just do a simple forward operation on an image. I've tried the following
import tensorflow as tf
sess = tf.Session()
model = tf.train.import_meta_graph('params.cifar.cpkt.meta')
model.restore(sess, 'params_cifar.cpkt')
E tensorflow/core/client/tensor_c_api.cc:485] Cannot assign a device to node 'Variable_1134': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
Assign: CPU
Variable: CPU
[[Node: Variable_1134 = Variable[container="", dtype=DT_FLOAT, shape=[100], shared_name="", _device="/device:GPU:0"]()]]
---------------------------------------------------------------------------
InvalidArgumentError Traceback (most recent call last)
<ipython-input-22-13b033dc4e64> in <module>()
----> 1 new_saver.restore(sess, 'params_cifar.ckpt')
/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.pyc in restore(self, sess, save_path)
1127 raise ValueError("Restore called with invalid save path %s" % save_path)
1128 sess.run(self.saver_def.restore_op_name,
-> 1129 {self.saver_def.filename_tensor_name: save_path})
1130
1131 @staticmethod
/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in run(self, fetches, feed_dict, options, run_metadata)
380 try:
381 result = self._run(None, fetches, feed_dict, options_ptr,
--> 382 run_metadata_ptr)
383 if run_metadata:
384 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _run(self, handle, fetches, feed_dict, options, run_metadata)
653 movers = self._update_with_movers(feed_dict_string, feed_map)
654 results = self._do_run(handle, target_list, unique_fetches,
--> 655 feed_dict_string, options, run_metadata)
656
657 # User may have fetched the same tensor multiple times, but we
/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
721 if handle is None:
722 return self._do_call(_run_fn, self._session, feed_dict, fetch_list,
--> 723 target_list, options, run_metadata)
724 else:
725 return self._do_call(_prun_fn, self._session, handle, feed_dict,
/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/client/session.pyc in _do_call(self, fn, *args)
741 except KeyError:
742 pass
--> 743 raise type(e)(node_def, op, message)
744
745 def _extend_graph(self):
InvalidArgumentError: Cannot assign a device to node 'Variable_1134': Could not satisfy explicit device specification '/device:GPU:0' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
Assign: CPU
Variable: CPU
[[Node: Variable_1134 = Variable[container="", dtype=DT_FLOAT, shape=[100], shared_name="", _device="/device:GPU:0"]()]]
Caused by op u'Variable_1134', defined at:
File "/home/user/miniconda2/bin/ipython", line 6, in <module>
sys.exit(IPython.start_ipython())
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/__init__.py", line 119, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/home/user/miniconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 348, in start
self.shell.mainloop()
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 455, in mainloop
self.interact()
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 446, in interact
self.run_cell(code, store_history=True)
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2821, in run_ast_nodes
if self.run_code(code, result):
File "/home/user/miniconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-15-d6797432c2fa>", line 1, in <module>
new_saver = tf.train.import_meta_graph('params_cifar.ckpt.meta')
File "/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1458, in import_meta_graph
return _import_meta_graph_def(read_meta_graph_file(meta_graph_or_file))
File "/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1348, in _import_meta_graph_def
producer_op_list=producer_op_list)
File "/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 279, in import_graph_def
op_def=op_def)
File "/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2310, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/home/user/miniconda2/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1232, in __init__
self._traceback = _extract_stack()