Tensoflow 2.12.0无法识别tensorflow.compiler.xla.experimental

snvhrwxg  于 2023-05-07  发布在  其他
关注(0)|答案(1)|浏览(167)

使用Bert代码,我看到下面的导入行:

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

这导致了这个错误:

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

下面你可以看到我安装的版本和包:

$ 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

一切看起来都很好,但我想知道到底是什么问题。编译器似乎是在TF-2.4.0中引入的,所以2.12.0应该可以。
我试着一步一步来

>>> 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)

你知道吗?

qxsslcnc

qxsslcnc1#

在Tensorflow 2.11.0发布期间,tensorflow.compiler.xla.experimental被移动到tensorflow.python.compiler.xla.experimental
查看commit:6ed611b

将TensorFlow xla_sharding python API从XLA移动到tensorflow/python...

.../compiler/xla
这是从XLA移除对TensorFlow的依赖
PiperOrigin-RevId:477339536

相关问题