【问题标题】:Tensorflow. Kernel died when training. Window Anaconda张量流。内核在训练时死亡。窗口蟒蛇
【发布时间】:2017-01-09 10:25:01
【问题描述】:
   # Import data

    from tensorflow.examples.tutorials.mnist import input_data
    import tensorflow as tf

    mnist = input_data.read_data_sets('/tmp/tensorflow/mnist/input_data', one_hot=True)

    # Create the model

    x = tf.placeholder(tf.float32, [None, 784])
    W = tf.Variable(tf.zeros([784, 10]))
    b = tf.Variable(tf.zeros([10]))
    k = tf.matmul(x, W) + b
    y = tf.nn.softmax(k)
    i = 0

    # Define loss and optimizer

    y_ = tf.placeholder(tf.float32, [None, 10])
    learning_rate = 0.5
    cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(k, y_))
    train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)

    print ("Training")
    sess = tf.Session()
    init = tf.global_variables_initializer() #.run()
    sess.run(init)
    for _ in range(1000):

        print(i)
        batch_xs, batch_ys = mnist.train.next_batch(100)
        print(i)
        sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})
        print(i)
        i=i+1


    print ('b is ',sess.run(b))
    print('W is',sess.run(W))

解释一下。

这是使用 softmax 的 MNIST 代码。 问题出现在

sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})

在 for 循环中。

只是内核死亡并重新启动并显示任何错误消息。 也许代码不是问题,因为它适用于其他人。

我正在使用 Windows10 Anaconda。

有什么问题?

【问题讨论】:

  • 从你提到的“内核”死亡,听起来你正在使用 Jupyter/IPython。如果您直接使用python.exe 运行脚本,您可能会获得更多信息,包括更好的错误消息。您可以尝试这样做并发布完整的错误消息吗?

标签: python debugging tensorflow anaconda


【解决方案1】:

我遇到了和你类似的问题。您可能安装了cudacudnn 并在tensorflow-gpu 上运行代码。

在我的情况下,我首先安装了cuda8.0cudnn v6.0 for cuda8.0,并遇到了内核死机的问题。

然后我把cudnn的版本改成cudnn v5.1 for cuda8.0就解决了这个问题。现在我可以很好地适应我的环境了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 2019-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多