bes-dev / stable_diffusion.openvino

Apache License 2.0
1.53k stars 208 forks source link

Problems installing on Ubuntu 22.04 #31

Closed mberg2007 closed 1 year ago

mberg2007 commented 1 year ago

Tried to install as described, I get this:

michael@michael-kontor:~/github/stable_diffusion.openvino$ pip install -r requirements.txt 
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy==1.19.5
  Using cached numpy-1.19.5.zip (7.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting opencv-python==4.5.5.64
  Using cached opencv_python-4.5.5.64-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.5 MB)
Collecting transformers==4.16.2
  Using cached transformers-4.16.2-py3-none-any.whl (3.5 MB)
Collecting diffusers==0.2.4
  Using cached diffusers-0.2.4-py3-none-any.whl (112 kB)
Collecting tqdm==4.64.0
  Using cached tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
ERROR: Could not find a version that satisfies the requirement openvino==2022.1.0 (from versions: none)
ERROR: No matching distribution found for openvino==2022.1.0

Info about my system:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy
$ uname -a
Linux michael-kontor 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
$ cat /proc/cpuinfo
(some info left out)
processor   : 6
vendor_id   : GenuineIntel
cpu family  : 6
model       : 158
model name  : Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
stepping    : 9
microcode   : 0xf0
cpu MHz     : 4200.000
cache size  : 8192 KB

Not much help to be found online regarding openvino except some lack of support with CentOS which I don't think is relevant on my machine.

Any ideas?

bes-dev commented 1 year ago

@mberg2007 Unfortunately, there is not OpenVINO release compatible to Ubuntu 22.04 yet :disappointed: https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/system-requirements.html

mberg2007 commented 1 year ago

@mberg2007 Unfortunately, there is not OpenVINO release compatible to Ubuntu 22.04 yet disappointed https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/system-requirements.html

Ah ... I see. So I'm looking at some sort of docker setup here to run this on a previous ubuntu version I guess.

Thanks for answering :-)

mberg2007 commented 1 year ago

@bes-dev ok so I'm now in a docker image, ubuntu 18.04:

Collecting openvino==2022.1.0
  Downloading openvino-2022.1.0-7019-cp36-cp36m-manylinux_2_27_x86_64.whl (26.1 MB)
     |################################| 26.1 MB 27.7 MB/s            
ERROR: Could not find a version that satisfies the requirement huggingface_hub==0.9.0 (from versions: 0.0.1, 0.0.2, 0.0.3rc1, 0.0.3rc2, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.0.19, 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.4.0)
ERROR: No matching distribution found for huggingface_hub==0.9.0

Looks like it downloads openvino now, but now I run into the same problem with huggingface hub.

bes-dev commented 1 year ago

@mberg2007 try to update pip:

pip install --upgrade pip
mberg2007 commented 1 year ago

I'm using pip3 - does that matter? (I'm no Python expert as you can tell :-)

bes-dev commented 1 year ago

It doesn't matter

pip3 install --upgrade pip3
mberg2007 commented 1 year ago
root@f628b1fd7a16:/Downloads/stable_diffusion.openvino# pip3 install --upgrade pip3
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
ERROR: Could not find a version that satisfies the requirement pip3 (from versions: none)
ERROR: No matching distribution found for pip3
root@f628b1fd7a16:/Downloads/stable_diffusion.openvino# pip3 --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 21.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
root@f628b1fd7a16:/Downloads/stable_diffusion.openvino#

Not sure what this wrapper business is about.

bes-dev commented 1 year ago

hmm, ok:

sudo apt-install python3-venv
python3 -m venv venv_tmp
source venv_tmp/bin/activate
pip install --upgrade pip
pip install openvino
mberg2007 commented 1 year ago

All commands executed with no errors. However there is still an issue with the huggingface dependency:

(venv_tmp) root@f628b1fd7a16:/Downloads/stable_diffusion.openvino# pip install -r requirements.txt 
Requirement already satisfied: numpy==1.19.5 in ./venv_tmp/lib/python3.6/site-packages (from -r requirements.txt (line 1)) (1.19.5)
Collecting opencv-python==4.5.5.64
  Using cached opencv_python-4.5.5.64-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.5 MB)
Collecting transformers==4.16.2
  Using cached transformers-4.16.2-py3-none-any.whl (3.5 MB)
Collecting diffusers==0.2.4
  Using cached diffusers-0.2.4-py3-none-any.whl (112 kB)
Collecting tqdm==4.64.0
  Using cached tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
Requirement already satisfied: openvino==2022.1.0 in ./venv_tmp/lib/python3.6/site-packages (from -r requirements.txt (line 6)) (2022.1.0)
ERROR: Could not find a version that satisfies the requirement huggingface_hub==0.9.0 (from versions: 0.0.1, 0.0.2, 0.0.3rc1, 0.0.3rc2, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 0.0.13, 0.0.14, 0.0.15, 0.0.16, 0.0.17, 0.0.18, 0.0.19, 0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.4.0)
ERROR: No matching distribution found for huggingface_hub==0.9.0
bes-dev commented 1 year ago

hmm, so strange. try to use huggingface_hub that available in your pip

impca commented 1 year ago

I managed to install this on 22.04 using https://github.com/pyenv/pyenv-virtualenv to install python3.9.9. No need to upgrade pip, the problem is that Ubuntu's default python version is 3.10. Do not use the default python version, instead use pyenv to install python3.9.9, go to the directory where the repo is, activate python3.9.9 and install all the required packages via pip install -r requirements.txt.

If pyenv install 3.9.9 fails during build, you will probably need some build dependencies. I had to install sudo apt install build-essential lbz2-dev ncurses-dev libffi-dev libssl-dev.

mberg2007 commented 1 year ago

@impca Whoa. I'm a developer but I'm completely new to Python and I'm afraid I don't have any idea what you mean by going to the directory where the repo is and how to activate python. Thanks anyway :-)

@bes-dev A small prayer from me that you would consider providing a docker image with the whole thing installed and ready to go. All this python stuff is a barrier for many, especially if it doesn't work as in my case. A docker image would make this so much easier to try.

impca commented 1 year ago

Here's a primer: https://realpython.com/intro-to-pyenv/

You basically install a separate version of python to a virtual environment and then use it to run stable_diffusion.

mberg2007 commented 1 year ago

@impca btw how did you manage to install openvino on ubuntu 22.04? According to https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/system-requirements.html it is not supported yet.

I worked around that by creating and running a Ubuntu 18.04 docker image. This solved the openvino issue, now it's just huggingface and whatever dependencies in requirements.txt come after that.

impca commented 1 year ago

As I said, I downgraded the python version to 3.9.9 using a python virtualenv:

$ pyenv virtualenvs 
* stable-diffusion (created from /home/xxx/.pyenv/versions/3.9.9)
  3.9.9/envs/stable-diffusion (created from /home/xxx/.pyenv/versions/3.9.9)

$ pip list | grep openvino
openvino              2022.1.0

If your prefer docker, you can use the provided Dockerfile to build an image: https://github.com/bes-dev/stable_diffusion.openvino/blob/master/Dockerfile that works (because Debian Bullseye has python 3.9 as default).

mberg2007 commented 1 year ago

@impca Thanks for the link to the dockerfile. I just tried it but the image doesn't appear to be working:

$ docker build -t sdtestvino .
(some lines excluded)
etting up libdrm-intel1:amd64 (2.4.104-1) ...
Setting up libgl1-mesa-dri:amd64 (20.3.5-1) ...
Setting up libglx-mesa0:amd64 (20.3.5-1) ...
Setting up libglx0:amd64 (1.3.2-1) ...
Setting up libgl1:amd64 (1.3.2-1) ...
Processing triggers for libc-bin (2.31-13+deb11u2) ...
Removing intermediate container 0b4478d663f8
 ---> 83b007f3ec73
Step 4/9 : COPY requirements.txt /src/
COPY failed: file not found in build context or excluded by .dockerignore: stat requirements.txt: file does not exist

It doesn't appear that the dockerfile is pulling in the stable diffusion openvino git repository. I can fix that easily, just pointing it out.

@bes-dev Is this anything you might be able to fix?

impca commented 1 year ago

Can you explain why would you want to do that? When you clone the bes-dev/stable_diffusion.openvino repository, all the files are already there.

mberg2007 commented 1 year ago

@impca You're right. It's just been too long since I last worked with docker. My apologizes, the Dockerfile is working fine once you start thinking .. :-)

mberg2007 commented 1 year ago

I'm going to close this issue as the docker image solves everything for me. Thanks @bes-dev for your efforts in doing this project and @impca for helping me out :-)