Reputation: 11
I'm getting the following error while importing Keras:
ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (C:\Users\User\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v2\experimental\__init__.py)
Tensorflow v. 2.6, Keras v. 2.6
Does anyone have an idea how to solve this error?
Upvotes: 1
Views: 1435
Reputation:
DTensor is part of the TensorFlow 2.9.0 release. To import dtensor
you can upgrade tensorflow 2.6
to tensorflow 2.9
as follows:
pip install --upgrade tensorflow==2.9
Now, you can import dtensor
either from tensorflow.experimental
or from tensorflow.keras
as follows:
#Using tensorflow.experimental
from tensorflow.experimental import dtensor
#Using tensorflow.keras
from tensorflow.keras import dtensor
For more information, please refer to this guide. Thank you.
Upvotes: 1