Andy
Andy

Reputation: 2762

Tensorflow 1.11 hangs on "sess = tf.Session()"

I updated to TensorFlow 1.11 from 1.10 and was unable to run a health-check. The below code hangs on sess = tf.Session().

Config: Windows 10 x64, latest GPU drivers, Cuda 9.0, cudnn 7.3, Python 3.6.6. This same setup used to work for TF 1.10, and all of a sudden everything stopped.

Did anybody else encounter a similar situation?

import os
import numpy as np
import tensorflow as tf

def tftest(a, b):
    # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3
    x_data = np.random.rand(100).astype(np.float32)
    y_data = x_data * a + b

    # Try to find values for W and b that compute y_data = W * x_data + b
    # (We know that W should be 0.1 and b 0.3, but TensorFlow will
    # figure that out for us.)
    W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
    b = tf.Variable(tf.zeros([1]))
    y = W * x_data + b

    # Minimize the mean squared errors.
    loss = tf.reduce_mean(tf.square(y - y_data))
    optimizer = tf.train.GradientDescentOptimizer(0.5)
    train = optimizer.minimize(loss)

    # Before starting, initialize the variables.  We will 'run' this first.
    init = tf.global_variables_initializer()

    # Launch the graph.
    sess = tf.Session()   #<< the script hangs here!
    sess.run(init)

    # Fit the line.
    for step in range(201):
        sess.run(train)
        if step % 20 == 0:
            print(step, sess.run(W), sess.run(b))

if __name__ == "__main__":
    tftest(20, 10)

Upvotes: 2

Views: 1511

Answers (1)

Andy
Andy

Reputation: 2762

I think it's this bug. The issue is still open, seems to be related to an issue in Eigen when built with MSVC.

The good news is that TensorFlow does not hang indefinitely: one has to wait for 3-4-5 minutes and then the codes resumes. This only happens once, on first startup of TensorFlow.

Upvotes: 2

Related Questions