1
~\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\tpu\python\tpu\tpu_estimator.py in <module>()
     38 from tensorflow.contrib.tpu.python.tpu import tpu_config
     39 from tensorflow.contrib.tpu.python.tpu import tpu_context
---> 40 from tensorflow.contrib.tpu.python.tpu import tpu_feed
     41 from tensorflow.contrib.tpu.python.tpu import training_loop
     42 from tensorflow.contrib.tpu.python.tpu import util as util_lib

~\AppData\Roaming\Python\Python36\site-packages\tensorflow\contrib\tpu\python\tpu\tpu_feed.py in <module>()
     26 from six.moves import xrange  # pylint: disable=redefined-builtin
     27 
---> 28 from tensorflow.compiler.xla.experimental.xla_sharding import xla_sharding
     29 from tensorflow.compiler.xla.python_api import xla_shape
     30 from tensorflow.contrib.tpu.python.ops import tpu_ops

ModuleNotFoundError: No module named 'tensorflow.compiler'

The above error occurred when I ran the following code: env:windows10+jupyter notebook+tensorflow1.9+python3.6

import tensorflow as tf
x_image = tf.reshape(x, [-1,24,24,3])
h_conv1 = tf.contrib.layers.conv2d(x_image, 64,5,1, "SAME", 
activation_fn=tf.nn.relu)
  • Can you please be more specific about your expected behaviour? It's not that unclear as in other questions. But better be explicit to avoid misunderstandings. – colidyre Aug 18 '18 at 13:57
  • This sounds like an environment gone awry during updates. What happens if you reinstall TensorFlow? – fuglede Aug 18 '18 at 15:00
  • I can not call the method "tf.contrib.layers.conv2d"The above error occurred when I call it – menghuanguaishou Aug 19 '18 at 12:54
  • It's not work when I reinstall the TensorFlow.the errors "No module named tensorflow.compiler" orrurs when I call method tf.contrib.layers.conv2d – menghuanguaishou Aug 19 '18 at 12:59
  • It will be ok when I call then method tf.nn.conv2d – menghuanguaishou Aug 19 '18 at 13:00
  • I ran your example using Python 3 on a Cloud TPU (ctpu) machine, defining `x` and initializing global variables as follows: `sess = tf.Session(); sess.run(tf.global_variables_initializer()); x = tf.ones(shape=[24*24*3*50], dtype=tf.float32); x_image = tf.reshape(x, [-1,24,24,3]); h_conv1 = tf.contrib.layers.conv2d(x_image, 64,5,1, "SAME", activation_fn=tf.nn.relu); sess.run(h_conv1) ` This seemed to work without trouble. Same for you? – Derek T. Jones Sep 01 '18 at 00:00
  • Thank you,Maybe there are some problems in jupyter.It works in pycharm – menghuanguaishou Sep 10 '18 at 06:17
  • Ok. I moved my comment to an answer, given your confirmation that it's not tensorflow- or TPU-specific. – Derek T. Jones Sep 27 '18 at 15:44
  • Also worth mentioning tf-trt its not supported on windows 10 https://forums.developer.nvidia.com/t/error-converting-tensorflow-model-to-tensorrt-on-windows-10/83892 – Martin Ivanov Oct 08 '20 at 22:15

2 Answers2

2

This error can happen if the installation of Tensorflow is incomplete (for example if "pip install tensorflow" has been interrupted.

0x4a6f4672
  • 27,297
  • 17
  • 103
  • 140
0

I ran your example using Python 3 on a Cloud TPU (ctpu) machine, defining x and initializing global variables as follows:

sess = tf.Session()
sess.run(tf.global_variables_initializer())
x = tf.ones(shape=[24*24*3*50], dtype=tf.float32)
x_image = tf.reshape(x, [-1,24,24,3])
h_conv1 = tf.contrib.layers.conv2d(x_image, 64,5,1, "SAME",
                                   activation_fn=tf.nn.relu)
sess.run(h_conv1)

and it worked correctly.

Derek T. Jones
  • 1,800
  • 10
  • 18