intel / intel-extension-for-tensorflow

Intel® Extension for TensorFlow*
Other
316 stars 40 forks source link

Error when enabling experimental ops #41

Closed Scot-Survivor closed 1 year ago

Scot-Survivor commented 1 year ago
Traceback (most recent call last):
  File "/home/u102359/GavinTraining/train.py", line 12, in <module>
    import intel_extension_for_tensorflow as itex
  File "/home/u102359/.local/lib/python3.10/site-packages/intel_extension_for_tensorflow/__init__.py", line 23, in <module>
    from intel_extension_for_tensorflow.python import ops  # pylint: disable=unused-import,line-too-long
  File "/home/u102359/.local/lib/python3.10/site-packages/intel_extension_for_tensorflow/python/ops/__init__.py", line 20, in <module>
    from intel_extension_for_tensorflow.python.ops.layer_norm import LayerNormalization
  File "/home/u102359/.local/lib/python3.10/site-packages/intel_extension_for_tensorflow/python/ops/layer_norm.py", line 39, in <module>
    from keras.engine.base_layer import Layer
ModuleNotFoundError: No module named 'keras.engine'

What is interesting is keras.engine does indeed exist, due to the fact Tensorflow is installed, I have my imports setup like this:

import tensorflow as tf
import tensorflow_datasets as tfds
import intel_extension_for_tensorflow as itex

there was a similar error with the hugging face repository, due to trying to import keras.engine directly, when it was in fact installed along side Tensorflow.

Installed packages:

absl-py==1.4.0
aiofiles==22.1.0
aiosqlite==0.19.0
alembic==1.11.1
anyio==3.7.1
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
array-record==0.4.0
arrow==1.2.3
asttokens==2.2.1
astunparse==1.6.3
async-lru==2.0.3
attrs==23.1.0
Babel==2.12.1
backcall==0.2.0
beautifulsoup4==4.12.2
bleach==6.0.0
cachetools==5.3.1
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.5
cmaes==0.9.1
colorlog==6.7.0
comm==0.1.3
debugpy==1.6.7
decorator==5.1.1
defusedxml==0.7.1
dm-tree==0.1.8
etils==1.3.0
exceptiongroup==1.1.2
executing==1.2.0
fastjsonschema==2.17.1
flatbuffers==23.5.26
fqdn==1.5.1
gast==0.4.0
google-auth==2.22.0
google-auth-oauthlib==1.0.0
google-pasta==0.2.0
googleapis-common-protos==1.59.1
greenlet==2.0.2
grpcio==1.56.0
h5py==3.9.0
idna==3.4
importlib-resources==6.0.0
intel-extension-for-tensorflow==1.2.0
intel-extension-for-tensorflow-lib==1.2.0.1
intel_tensorflow==2.12.0
ipykernel==6.24.0
ipython==8.14.0
ipython-genutils==0.2.0
isoduration==20.11.0
jax==0.4.13
jedi==0.18.2
Jinja2==3.1.2
joblib==1.3.1
json5==0.9.14
jsonpointer==2.3
jsonschema==4.18.3
jsonschema-specifications==2023.6.1
jupyter-events==0.6.3
jupyter-lsp==2.2.0
jupyter-ydoc==0.2.4
jupyter_client==8.3.0
jupyter_core==5.3.1
jupyter_server==2.7.0
jupyter_server_fileid==0.9.0
jupyter_server_terminals==0.4.4
jupyter_server_ydoc==0.8.0
jupyterlab==3.6.5
jupyterlab-pygments==0.2.2
jupyterlab-simpledark==1.0.0
jupyterlab_server==2.23.0
keras==2.13.1
libclang==16.0.6
linecache2==1.0.0
Mako==1.2.4
Markdown==3.4.3
MarkupSafe==2.1.3
matplotlib-inline==0.1.6
mistune==3.0.1
ml-dtypes==0.2.0
nbclassic==1.0.0
nbclient==0.8.0
nbconvert==7.7.1
nbformat==5.9.1
nest-asyncio==1.5.6
nltk==3.8.1
notebook==6.5.4
notebook_shim==0.2.3
numpy==1.23.5
oauthlib==3.2.2
opt-einsum==3.3.0
optuna==3.2.0
overrides==7.3.1
packaging==23.1
pandas==2.0.3
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
platformdirs==3.9.1
prometheus-client==0.17.1
promise==2.3
prompt-toolkit==3.0.39
protobuf==4.23.4
psutil==5.9.5
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
pydot==1.4.2
Pygments==2.15.1
pyparsing==3.1.0
pyrsistent==0.19.3
python-dateutil==2.8.2
python-dotenv==1.0.0
python-json-logger==2.0.7
pytz==2023.3
PyYAML==6.0
pyzmq==25.1.0
referencing==0.29.1
regex==2023.6.3
requests==2.31.0
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.8.11
rsa==4.9
scipy==1.11.1
Send2Trash==1.8.2
six==1.16.0
sniffio==1.3.0
soupsieve==2.4.1
SQLAlchemy==2.0.19
stack-data==0.6.2
tensorboard==2.13.0
tensorboard-data-server==0.7.1
tensorflow==2.13.0
tensorflow-datasets==4.9.2
tensorflow-estimator==2.13.0
tensorflow-io-gcs-filesystem==0.32.0
tensorflow-metadata==1.13.1
termcolor==2.3.0
terminado==0.17.1
tinycss2==1.2.1
toml==0.10.2
tomli==2.0.1
tornado==6.3.2
tqdm==4.65.0
traceback2==1.4.0
traitlets==5.9.0
typing_extensions==4.5.0
tzdata==2023.3
unittest2==1.1.0
uri-template==1.3.0
urllib3==1.26.16
wcwidth==0.2.6
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.1
Werkzeug==2.3.6
wrapt==1.14.1
y-py==0.5.9
ypy-websocket==0.8.2
zipp==3.16.2
zstandard==0.21.0
Scot-Survivor commented 1 year ago

Explitictly I run:

itex.set_backed('GPU')
itex.experimental_ops_override()

After the imports mentioned above.

guizili0 commented 1 year ago

@Scot-Survivor This issue is due to the keras api change, please try with TensorFlow version 2.12 and keras 2.12

Scot-Survivor commented 1 year ago

I can confirm after a downgrade this error has gone away.