Issue 1:
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow):

Yes.

OS Platform and Distribution (e.g., Linux Ubuntu 16.04):

Linux Ubuntu 16.04.3

TensorFlow installed from (source or binary):

Binary.

TensorFlow version (use command below):

1.3.0

Python version:

2.7.12

CUDA/cuDNN version:

CUDA Version 8.0.61

GPU model and memory:

NVIDIA GTX 1080Ti 12G

Describe the problem

If I import cv2, " tf.global_variables_initializer() " will be very slow, about 143s. You can run my test code below, when " import cv2 " is commented out, the time is about 5s. The version of opencv is 2.4.13.4.

Source code / logs

import tensorflow as tf
import time
import cv2

weight = tf.Variable(tf.truncated_normal([5,5,1,32], stddev=0.1))

ot = time.time()
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
nt = time.time()
print('time: {:.3f}'.format(nt-ot))

Issue 2:
Please go to Stack Overflow for help and support:

https://stackoverflow.com/questions/tagged/tensorflow

If you open a GitHub issue, here is our policy:

It must be a bug, a feature request, or a significant problem with documentation (for small docs fixes please send a PR instead).

The form below must be filled out.

It shouldn't be a TensorBoard issue. Those go here.

Here's why we have that policy: TensorFlow developers respond to issues. We want to focus on work that benefits the whole community, e.g., fixing bugs and adding features. Support only helps individuals. GitHub also notifies thousands of people when issues are filed. We want them to see you communicating an interesting problem, rather than being redirected to Stack Overflow.

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): N/A

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): OS 10.13.4

Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A

TensorFlow installed from (source or binary): source (whole package)

TensorFlow version (use command below): 1.10.1

Python version: 3.7

Bazel version (if compiling from source): N/A

GCC/Compiler version (if compiling from source):

Apple LLVM version 9.1.0 (clang-902.0.39.1)

Target: x86_64-apple-darwin17.5.0

Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin

CUDA/cuDNN version: N/A

GPU model and memory: N/A

Exact command to reproduce:

run the following below:

import numpy as np

import tensorflow as tf

import tensorflow

from tensorflow import keras

from keras.models import Sequential

from keras.layers import Embedding

model = Sequential()

model.add(Embedding(5, 2, input_length=5))

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with:

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

So it appears Tensorflow doesn't play nicely with Python 3.7 - there is a source issue when I run ANY tensorflow or keras command using python 3.7 (but runs perfectly fine with earlier versions of python - reverted back and everything ran perfectly fine).

Here are all the relevant files with environment (it actually errors out when running in p3.7)

files using 3.7:

broken-old-tf_env.txt

broken-tf_env.txt

normal env:

old-tf_env.txt

tf_env.txt

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

Here is the trace error message - this exact message occurs when attempting to run ANY keras or tf command using python 3.7:

(for test case, honestly even the most simple lines will cause the break - try;

embeddings = tf.Variable(tf.random_uniform([vocabulary_size, embedding_size], -1.0, 1.0))

Or for keras:

model = Sequential()

model.add(Embedding(10000, 50, input_length=3334))

Error message:

UnboundLocalError Traceback (most recent call last)

in ()

6 embedding_size = 100

7

----> 8 embeddings = tf.Variable(tf.random_uniform([vocabulary_size, embedding_size], -1.0, 1.0))

9 nce_weights = tf.Variable(tf.truncated_normal([vocabulary_size, embedding_size], stddev=1.0 / math.sqrt(embedding_size)))

10 nce_biases = tf.Variable(tf.zeros([vocabulary_size]))

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/ops/random_ops.py in random_uniform(shape, minval, maxval, dtype, seed, name)

233 with ops.name_scope(name, "random_uniform", [shape, minval, maxval]) as name:

234 shape = _ShapeTensor(shape)

--> 235 minval = ops.convert_to_tensor(minval, dtype=dtype, name="min")

236 maxval = ops.convert_to_tensor(maxval, dtype=dtype, name="max")

237 seed1, seed2 = random_seed.get_seed(seed)

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, preferred_dtype)

996 name=name,

997 preferred_dtype=preferred_dtype,

--> 998 as_ref=False)

999

1000

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx)

1092

1093 if ret is None:

-> 1094 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)

1095

1096 if ret is NotImplemented:

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in _constant_tensor_conversion_function(v, dtype, name, as_ref)

215 as_ref=False):

216 _ = as_ref

--> 217 return constant(v, dtype=dtype, name=name)

218

219

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name, verify_shape)

194 tensor_value.tensor.CopyFrom(

195 tensor_util.make_tensor_proto(

--> 196 value, dtype=dtype, shape=shape, verify_shape=verify_shape))

197 dtype_value = attr_value_pb2.AttrValue(type=tensor_value.tensor.dtype)

198 const_tensor = g.create_op(

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)

534 raise TypeError(

535 "Element type not supported in TensorProto: %s" % numpy_dtype.name)

--> 536 append_fn(tensor_proto, proto_values)

537

538 return tensor_proto

tensorflow/python/framework/fast_tensor_util.pyx in tensorflow.python.framework.fast_tensor_util.AppendFloat32ArrayToTensorProto()

~/.local/share/virtualenvs/embedded-feature-extraction-o8pNKOHv/lib/python3.7/site-packages/google/protobuf/internal/containers.py in append(failed resolving arguments)

249 def append(self, value):

250 """Appends an item to the list. Similar to list.append()."""

--> 251 self._values.append(self._type_checker.CheckValue(value))

252 if not self._message_listener.dirty:

253 self._message_listener.Modified()

UnboundLocalError: local variable 'self' referenced before assignment