Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How could I installl itex with intel-tensorflow instead of stock tensorflow? #23

Closed
Oscilloscope98 opened this issue Feb 17, 2023 · 6 comments
Labels
aitce question Further information is requested

Comments

@Oscilloscope98
Copy link

Hi!

As the discussion here that

itex can work well with tensorflow or intel-tensorflow

So, before install itex, only need to install one of intel tensorflow or stock tensorflow

I am trying to install itex after installing intel-tensorflow (without stock tensorflow) as follows:

[~]# pip list | grep tensorflow
intel_tensorflow             2.10.0
tensorflow-estimator         2.10.0
tensorflow-io-gcs-filesystem 0.30.0

[~]# pip install --upgrade intel-extension-for-tensorflow[cpu]
Collecting intel-extension-for-tensorflow[cpu]
  Using cached intel_extension_for_tensorflow-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (121 kB)
Requirement already satisfied: wheel in /root/miniconda3/envs/test/lib/python3.8/site-packages (from intel-extension-for-tensorflow[cpu]) (0.37.1)
Requirement already satisfied: grpcio>=1.8.6 in /root/miniconda3/envs/test/lib/python3.8/site-packages (from intel-extension-for-tensorflow[cpu]) (1.51.1)
Collecting numpy<1.24
  Using cached numpy-1.23.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
Collecting tensorflow>=2.10
  Downloading tensorflow-2.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.3 MB)
     ━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 126.4/588.3 MB 11.0 MB/s eta 0:00:42

However, it seems that itex requires tensorflow >= 2.10 in its setup requirements, and will still automatically install tensorflow >= 2.10 even though intel-tensorflow==2.10.0 is already installed.

Could you let me know how to resolve this problem? Thank you!

@NeoZhangJianyu
Copy link
Contributor

@Oscilloscope98
Here are two bugs:

  1. ITEX install stock TF automatically when there is already intel tensorflow is installed.
    Because stock TF and Intel TF can't detect to each other. I will report to dev team.

Solution:
for your case, please remove Intel tensorflow, stock tensorflow and ITEX in same time. It will make the environment is clear and correct.
Then install ITEX again. ITEX will install the right tensorflow automatically.

  1. Installation guide.
    Correct info:
    ITEX 1.0 need TF 2.10 or newer.
    ITEX 1.1 need TF 2.11 or newer.
    We will update the guide for this part.

ITEX installation will help install the right release of tensorflow automatically.
No warry about it.

Thank you!

@MateuszGrabuszynski
Copy link

I write this because I am trying to resolve #31, saw this issue, and got even more confused.

Solution: for your case, please remove Intel tensorflow, stock tensorflow and ITEX in same time. It will make the environment is clear and correct. Then install ITEX again. ITEX will install the right tensorflow automatically.

Spot on, ITEX does not require an installation of intel-tensorflow, but does require tensorflow. Have I understood right, that intel-tensorflow package is not at all installed, and it is not required, nor recommended to install it? Above would imply intel-tensorflow and tensorflow should not be present at the same time among installed packages, but only tensorflow.

Does not seems right to me when checking the documentation (where ITEX is installed post intel-tensorflow, and tensorflow is then as a dependency of ITEX) and Docker images (consisting of only intel-tensorflow and ITEX).

At the same time, on a clean system (Ubuntu 20.04), after

export INTEL_EXTENSION_FOR_TENSORFLOW_VER=="1.1.0"
export INTEL_TENSORFLOW_VER="2.11.0"

apt -o Acquire::Check-Date=false update && apt install -y python3 python3-pip && ln -s /usr/bin/python3 /usr/bin/python

pip install intel-tensorflow==${INTEL_TENSORFLOW_VER}
pip install --upgrade intel-extension-for-tensorflow[cpu]==${INTEL_EXTENSION_FOR_TENSORFLOW_VER} "tensorflow == 2.11.0"
# specifying tf version is a workaround for #31

both intel-tensorflow and tensorflow are present, and import intel_extension_for_tensorflow works.

But if I add

pip uninstall -y tensorflow

to the mix at the end (so only intel-tensorflow is present, should not uninstall tensorflow's dependencies), then it throws errors

root@x:/# python
Python 3.8.10 (default, Mar 13 2023, 10:26:41) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import intel_extension_for_tensorflow as itex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/intel_extension_for_tensorflow/__init__.py", line 19, in <module>
    from intel_extension_for_tensorflow.python.device import set_backend  # pylint: disable=unused-import
  File "/usr/local/lib/python3.8/dist-packages/intel_extension_for_tensorflow/python/device.py", line 21, in <module>
    from intel_extension_for_tensorflow.python._pywrap_itex import *
ImportError: libitex_common.so: cannot open shared object file: No such file or directory

Perhaps it can be resolved somehow without installing tensorflow. If so, do you know how? Or maybe there is a way to ensure intel-tensorflow is used when tensorflow is installed? Is it still beneficial to install intel-tensorflow instead of tensorflow, or all improvements are implemented within non-intel? If so, which version is the one that aligned those, 2.11?

@yinghu5 yinghu5 added the aitce label Apr 17, 2023
@NeoZhangJianyu
Copy link
Contributor

@MateuszGrabuszynski
Thank you to share you issues. I try to answer all.
If I missed any, please hint me.

  1. Intel Tensorflow is used to replace stock Tensorflow (Google Tensorflow) to optimize on Intel CPU.
    But they have little different since 2.9 release, because stock Tensorflow 2.9 and newer has set oneDNN as default code path, which is same as Intel Tensorflow.

  2. DON'T install Intel TF and stock TF in same time.
    It's recommended to install one of them (Intel TF or stock TF)
    When install Intel TF and stock TF in same time, they won't detect for each other.
    So, it's possible to install them in same time, but the impact is unknown.
    The issue after uninstall stock TF would be such unknown issue.

  3. For Intel GPU, ITEX+stock TF is only solution by now.
    ITEX is designed to work with stock TF.
    DON‘T install Intel TF with ITEX.

  4. For Intel CPU, ITEX+stock TF will replace Intel TF in this year.
    By now, ITEX for CPU is experimental.
    DON‘T install Intel TF with ITEX.

@MateuszGrabuszynski
Copy link

Thank you. I get it. 👍 Will probably use ITEX + stock TF or your dockerhub base image.

It seems the comment from #22 is not up to date anymore.

@Oscilloscope98 intel-tensorflow is a clone of stock tensorflow. intel-tensorflow follows stock tensorflow version and base code/feature. It's independent product and distributed. It's added to Intel optimization for Tensorflow.

intel-extension-for-tensorflow is a plugin which must cooperate with stock tensorflow or intel-tensorflow. tensorflow + itex can cover the most of optimization of intel-tensorflow on Intel CPU, because some features can't be implemented in a plugin. That's why intel-tensorflow will be present after itex is released.

In the future, most new features will be implemented in itex.

itex can work well with tensorflow or intel-tensorflow. In the guide, tensorflow>=2.10.0 is for both stock tensorflow and intel-tensorflow, because intel-tensorflow follows stock tensorflow's version, code and base feature.

So, before install itex, only need to install one of intel tensorflow or stock tensorflow.

@NeoZhangJianyu
Copy link
Contributor

Yes!
We are updating the FAQ to explain the relationship of ITEX, Stock Tensorflow and Intel Tensorflow.
After it's ready, I will paste the link here.

@yinghu5
Copy link

yinghu5 commented Oct 8, 2023

We have some explained in latest webniar, you are welcomed to take a look: https://www.intel.com/content/www/us/en/developer/videos/leverage-features-of-intel-tensorflow-on-gpu-cpu.html#gs.646by4

@yinghu5 yinghu5 closed this as completed Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aitce question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants