【发布时间】:2018-04-25 02:27:27
【问题描述】:
以下代码将挂起(只有 CTRLz 让我退出)。
import tensorflow as tf
import cifar10 # from https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10 (both cifar10.py & cifar10_input.py)
def main():
print 'TensorFlow version: ',tf.__version__
with tf.Session() as sess:
with tf.device('/cpu:0'):
images, labels = cifar10.distorted_inputs()
input = tf.constant([[[1, 2, 3], [5, 5, 5]], [[4, 5, 6], [7, 7, 7]], [[7, 8, 9], [9, 9, 9]]])
one=input[0]
print "X1 ",type(input), one
oneval = sess.run(one)
print "X2 ",type(one), one, type(oneval), oneval
two=images[0]
print "Y1 ",type(images), two
twoval = sess.run(two)
print "Y2 ",type(two), two, type(twoval), twoval
main()
我得到以下输出(使用 Python 2.7.5):
[gpu@centos-7-4 demo]$ python demo.py
TensorFlow version: 1.2.1
2017-07-31 16:06:45.503157: 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-07-31 16:06:45.503182: 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-07-31 16:06:45.503187: 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.
Filling queue with 20000 CIFAR images before starting to train. This will take a few minutes.
X1 class 'tensorflow.python.framework.ops.Tensor'> Tensor("strided_slice:0", shape=(2, 3), dtype=int32)
X2 class 'tensorflow.python.framework.ops.Tensor'> Tensor("strided_slice:0", shape=(2, 3), dtype=int32) <type 'numpy.ndarray'> [[1 2 3] [5 5 5]]
Y1 class 'tensorflow.python.framework.ops.Tensor'> Tensor("strided_slice_1:0", shape=(24, 24, 3), dtype=float32)
^Z
有人有什么建议(或解决方案)吗?
如果有人对背景感兴趣,我的最终目标是将distorted_inputs()返回的张量转换为一组JSON对象。所以天真的计划是遍历图像的每个元素并提取值。
【问题讨论】:
-
你离开它多久了?我认为加载图像可能只需要一段时间。你是在 CPU 还是 GPU 上运行它?
-
它已经运行了 5 分钟。顶部显示没有活动。 strace 显示 FUTEX_WAIT_PRIVATE。当我运行真正的程序(cifar10_train.py)时,它会立即开始批量运行,所以我不会期望延迟。
-
这一切都在 CPU 上(据我所知)——在无法访问 GPU 的 VM 中运行。我假设 TensorFlow 知道没有 GPU。
标签: python session tensorflow