I have tried to use the checkpoint to resume my graph but have no luck. After much tries I decided to run the demo code at http://cv-tricks.com/tensorflow-tutorial/save-restore-tensorflow-models-quick-complete-tutorial/ and this doesn't work either.
I'm using the newest tensorflow 1.1.0 with GPU build.
Here's the demo code I have used:
saver.py
import tensorflow as tf
w1 = tf.Variable(tf.random_normal(shape=[2]), name='w1')
w2 = tf.Variable(tf.random_normal(shape=[5]), name='w2')
saver = tf.train.Saver()
sess = tf.Session()
sess.run(tf.global_variables_initializer())
saver.save(sess, 'my_test_model')
restore.py
import tensorflow as tf
with tf.Session() as sess:
saver = tf.train.import_meta_graph('my_test_model.meta')
saver.restore(sess,tf.train.latest_checkpoint('./'))
print(sess.run(w1))
Console output
me@ubuntu:~/Projects/playground$ python3 saver.py
2017-05-11 17:12:16.833443: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:16.833469: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:16.833476: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:16.833481: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:16.833486: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:17.085355: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.7335
pciBusID 0000:06:00.0
Total memory: 7.92GiB
Free memory: 7.81GiB
2017-05-11 17:12:17.085421: W tensorflow/stream_executor/cuda/cuda_driver.cc:485] creating context when one is currently active; existing: 0x2a74b80
2017-05-11 17:12:17.299874: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 1 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.7335
pciBusID 0000:05:00.0
Total memory: 7.92GiB
Free memory: 7.30GiB
2017-05-11 17:12:17.300703: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 1
2017-05-11 17:12:17.300716: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y Y
2017-05-11 17:12:17.300723: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 1: Y Y
2017-05-11 17:12:17.300732: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:06:00.0)
2017-05-11 17:12:17.300739: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080, pci bus id: 0000:05:00.0)
me@ubuntu:~/Projects/playground$ python3 restore.py
2017-05-11 17:12:26.689147: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:26.689174: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:26.689182: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:26.689188: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:26.689194: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-05-11 17:12:26.950831: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.7335
pciBusID 0000:06:00.0
Total memory: 7.92GiB
Free memory: 7.81GiB
2017-05-11 17:12:26.950894: W tensorflow/stream_executor/cuda/cuda_driver.cc:485] creating context when one is currently active; existing: 0x25565b0
2017-05-11 17:12:27.159857: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 1 with properties:
name: GeForce GTX 1080
major: 6 minor: 1 memoryClockRate (GHz) 1.7335
pciBusID 0000:05:00.0
Total memory: 7.92GiB
Free memory: 7.30GiB
2017-05-11 17:12:27.160708: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 1
2017-05-11 17:12:27.160722: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y Y
2017-05-11 17:12:27.160729: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 1: Y Y
2017-05-11 17:12:27.160742: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:06:00.0)
2017-05-11 17:12:27.160750: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080, pci bus id: 0000:05:00.0)
Traceback (most recent call last):
File "restore.py", line 6, in <module>
print(sess.run(w1))
NameError: name 'w1' is not defined
I believe what I have read means that w1
should be auto-created as a result of restoring.
Any thought on this would be welcomed. Thank you!