Tensor2tensor: can't load the ckpt file

Created on 13 Mar 2018  路  1Comment  路  Source: tensorflow/tensor2tensor

Description

>
I run the command in the readme.md, and then I want to load the model in the ckpt files and run it, but it failed

TensorFlow and tensor2tensor versions

>
tensorflow 1.6
t2t latest

In case of bug report: Steps to reproduce the problem

>
my code:

import tensorflow as tf

with tf.Session() as sess:
    new_saver = tf.train.import_meta_graph('t2t_train/mnist/model.ckpt-1.meta')
    new_saver.restore(sess, 't2t_train/mnist/model.ckpt-1')

In case of bug report: Error log


>

error:

2018-03-13 11:01:52.672019: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1070, pci bus id: 0000:06:00.0, compute capability: 6.1)
Traceback (most recent call last):
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
    return fn(*args)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1293, in _run_fn
    self._extend_graph()
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1354, in _extend_graph
    self._session, graph_def.SerializeToString(), status)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'save/ShardedFilename_1': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
ShardedFilename: CPU
     [[Node: save/ShardedFilename_1 = ShardedFilename[_device="/device:GPU:0"](save/StringJoin, save/ShardedFilename_1/shard, save/num_shards)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "getgraph.py", line 5, in <module>
    new_saver.restore(sess, 't2t_train/mnist/model.ckpt-1')
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 1666, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 889, in run
    run_metadata_ptr)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1120, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
    options, run_metadata)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation 'save/ShardedFilename_1': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
ShardedFilename: CPU
     [[Node: save/ShardedFilename_1 = ShardedFilename[_device="/device:GPU:0"](save/StringJoin, save/ShardedFilename_1/shard, save/num_shards)]]

Caused by op 'save/ShardedFilename_1', defined at:
  File "getgraph.py", line 4, in <module>
    new_saver = tf.train.import_meta_graph('t2t_train/mnist/model.ckpt-1.meta')
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/training/saver.py", line 1810, in import_meta_graph
    **kwargs)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/framework/meta_graph.py", line 660, in import_scoped_meta_graph
    producer_op_list=producer_op_list)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/util/deprecation.py", line 316, in new_func
    return func(*args, **kwargs)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/framework/importer.py", line 314, in import_graph_def
    op_def=op_def)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 2960, in create_op
    op_def=op_def)
  File "/home/lyt/.local/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1473, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'save/ShardedFilename_1': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
ShardedFilename: CPU
     [[Node: save/ShardedFilename_1 = ShardedFilename[_device="/device:GPU:0"](save/StringJoin, save/ShardedFilename_1/shard, save/num_shards)]]

As the report, it said that Cannot assign a device for operation 'save/ShardedFilename_1': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available. but I did not change my machine.

question

Most helpful comment

try

config = tf.ConfigProto(allow_soft_placement=True)
with tf.Session(config=config) as sess:
  your codes here ...

>All comments

try

config = tf.ConfigProto(allow_soft_placement=True)
with tf.Session(config=config) as sess:
  your codes here ...
Was this page helpful?
0 / 5 - 0 ratings