Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Tensoflow 2.12.0 does not recognize tensorflow.compiler.xla.experimental

Using the Bert code, I see this import line:

from tensorflow.compiler.xla.experimental.xla_sharding import xla_sharding

which causes this error:

ModuleNotFoundError: No module named 'tensorflow.compiler.xla.experimental'

Below you can see the versions and packages I have installed:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

$ pip list | grep tensorflow
tensorflow                        2.12.0
tensorflow-addons                 0.20.0
tensorflow-estimator              2.12.0
tensorflow-io-gcs-filesystem      0.32.0


$ find python3.8/site-packages/ -name compiler
python3.8/site-packages/google/protobuf/compiler
python3.8/site-packages/tensorflow/python/compiler
python3.8/site-packages/tensorflow/xla_aot_runtime_src/tensorflow/compiler
python3.8/site-packages/tensorflow/compiler
python3.8/site-packages/tensorflow/include/google/protobuf/compiler
python3.8/site-packages/tensorflow/include/tensorflow/compiler
python3.8/site-packages/jedi/third_party/typeshed/third_party/2and3/google/protobuf/compiler


$ python3 --version
Python 3.8.10

Everything looks fine, but I wonder what the problem exactly. The compiler seems to be introduced in TF-2.4.0, so 2.12.0 should be fine with that.

I tried step-by-step and see

>>> from tensorflow.compiler import xla
>>> from tensorflow.compiler.xla import experimental
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'experimental' from 'tensorflow.compiler.xla' (/home/mahmood/.local/lib/python3.8/site-packages/tensorflow/compiler/xla/__init__.py)

Any idea about that?

>Solution :

tensorflow.compiler.xla.experimental was moved to tensorflow.python.compiler.xla.experimental during the release of Tensorflow 2.11.0.

See the commit: 6ed611b:

Move TensorFlow xla_sharding python API from XLA to
tensorflow/python…

…/compiler/xla

This is removing a dependency from XLA to TensorFlow

PiperOrigin-RevId: 477339536

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading