[go: nahoru, domu]

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

Update torch and other dependencies to make it work on 24.04 #15716

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

janbernloehr
Copy link

Description

Ubuntu 24.04 comes with python 3.12 and a newer rustc. This requires to update torch to 2.2+ which is available for py3.12 and also transformers to 4.34+ since only then tokenizers is new enough to build with the provided rustc.

Screenshots/videos:

Checklist:

@HinaHyugaHime
Copy link
Contributor

you forgot AMD changes

@cryptoquick
Copy link

I tried this out on amdgpu on arch linux and it worked fine actually 👍
I just had to set pytorch_lightning back to 1.9.4 in requirements_versions.txt

@janbernloehr
Copy link
Author

@HinaHyugaHime what do you mean by amd changes? I would be glad to provide them.

@HinaHyugaHime
Copy link
Contributor

@HinaHyugaHime what do you mean by amd changes? I would be glad to provide them.

Torch version

@AUTOMATIC1111
Copy link
Owner

CLIPTextModel_from_pretrained change should not be there. This code is to prevent loading CLIP model from the web as its weights are already included into the checkpoint, and removing None disables that.

As for the rest, I'm generally against updating versions without an explicit need for it... Does this all work on Windows with recommended python 3.10.6?

@viking1304
Copy link
viking1304 commented Jun 16, 2024

@janbernloehr I finally fixed Torch hell for MacOS with this PR, so please do not modify webui-macos-env.sh when you are fixing problems for other OS. Intel Macs must stay on 2.1.2 until they stop working compleately.

Have you tried just to change python and torch in webui-env.sh without moddifing anything else?

Something like:

python_cmd="python3.12"
export TORCH_COMMAND="pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121"

If that works I have another suggestion.

As for the rest, I'm generally against updating versions without an explicit need for it... Does this all work on Windows with recommended python 3.10.6?

@AUTOMATIC1111 If what I proposed above works, I would suggest similar approach as we have for MacOS.

Something like:

if [[ "${OSTYPE}" == "linux"* ]] && some_other_check; then
    if [[ -f "$SCRIPT_DIR"/webui-new-linux-env.sh ]]
        then
        source "$SCRIPT_DIR"/webui-new-linux-env.sh
    fi
fi

I am not sure what some_other_check should be. Something like [[ $(grep -c "Ubuntu 24" /etc/issue) -ne 0 ]] would work in this case, but it should be some more generic check.

@viking1304
Copy link

@janbernloehr I managed to run A1111 with 3.12 on my Mac with just a few minor changes. I only have Ubuntu 20.04.6 (on a server without GPU) so I can't test if this work on 24.x with Nvidia.

I only changed this:

webui-user sh

# python3 executable
- #python_cmd="python3"
+ python_cmd="python3.12"

# install command for torch
- #export TORCH_COMMAND="pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113"
+ export TORCH_COMMAND="pip install torch==2.3.0 torchvision==0.18.0"

requirements_versions.txt

- transformers==4.30.2
+ transformers==4.41.2

I haven't changed requirements.txt, since it is for colab users.

And I used ./webui.sh --skip-python-version-check to suppress version warnings.

Thats all.

After I remove venv, on the first run I am always getting this error, even setuptools==69.5.1 exists in :

    from distutils.version import StrictVersion
ModuleNotFoundError: No module named 'distutils

But if I just rerun ./webui again it works 🤷🏻‍♂️

I am getting the error below every time, since I haven't replace None with pretrained_model_name_or_path in CLIPTextModel_from_pretrained:

    raise EnvironmentError(
OSError: None is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`

Failed to create model quickly; will retry using slow method.

Otherwise it works fine as far as I can tell.

@AUTOMATIC1111 If you don't mind, I will reopen #13667 with a steps to reproduce and a note that I noticed that problem only with 3.12 and not with 3.10.

@janbernloehr that is the reason I am not using the pretrained_model_name_or_path patch you used.

Slow method works just fine:

Applying attention optimization: sub-quadratic... done.
Model loaded in 8.4s (load weights from disk: 0.3s, create model: 1.7s, apply weights to model: 5.8s, apply half(): 0.2s, calculate empty prompt: 0.2s).

All test passed:

33 passed, 60 warnings in 74.66s (0:01:14)

and basic generation works fine (I just did some basic tests):

Steps: 20, Sampler: DPM++ 2M, Schedule type: Karras, CFG scale: 7, Seed: 1341933258, Size: 512x512, Model hash: 6ce0161689, Model: v1-5-pruned-emaonly, Version: v1.9.4

Time taken: 11.3 sec.
version: v1.9.4  •  python: 3.12.4  •  torch: 2.3.0  •  xformers: N/A  •  gradio: 3.41.2  •  checkpoint: 6ce0161689

@janbernloehr
Copy link
Author

@viking1304 : thanks for your input - indeed this is very minimal changes! My intention of this PR was to fix all the weird things too so that’s why I in the end updated a lot more deps. But I see that this might cause some unforeseen problems for some users.

@viking1304
Copy link
viking1304 commented Jun 25, 2024

@janbernloehr

EDIT:
I had to completely change my message since this issue was brought to my attention last night:

PyTorch support for Python 3.12 in general is considered experimental. Please use Python version between 3.8 and 3.11 instead. This is an existing issue since PyTorch 2.2.

from https://github.com/pytorch/pytorch/releases/tag/v2.3.0

So, it would be better to find another solution instead of trying to make a1111 run on Python 3.12 since PyTorch, which is the most important package, does not work with 3.12 properly.

Can you please try this?

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants