Skip to content

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

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

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions modules/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def check_versions():
import torch
import gradio

expected_torch_version = "2.1.2"
expected_xformers_version = "0.0.23.post1"
expected_torch_version = "2.3.0"
expected_xformers_version = "0.0.26.post1"
expected_gradio_version = "3.41.2"

if version.parse(torch.__version__) < version.parse(expected_torch_version):
Expand Down
3 changes: 3 additions & 0 deletions modules/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def imports():
import sgm.modules.encoders.modules # noqa: F401
startup_timer.record("import sgm")

from modules import initialize_util
initialize_util.fix_pytorch_lightning()

from modules import shared_init
shared_init.initialize()
startup_timer.record("initialize shared")
Expand Down
8 changes: 4 additions & 4 deletions modules/launch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def requirements_met(requirements_file):

def prepare_environment():
torch_index_url = os.environ.get('TORCH_INDEX_URL', "https://download.pytorch.org/whl/cu121")
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url {torch_index_url}")
torch_command = os.environ.get('TORCH_COMMAND', f"pip install torch==2.3.0 torchvision==0.18.0 --extra-index-url {torch_index_url}")
if args.use_ipex:
if platform.system() == "Windows":
# The "Nuullll/intel-extension-for-pytorch" wheels were built from IPEX source for Intel Arc GPU: https://github.com/intel/intel-extension-for-pytorch/tree/xpu-main
Expand All @@ -340,9 +340,9 @@ def prepare_environment():
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
requirements_file_for_npu = os.environ.get('REQS_FILE_FOR_NPU', "requirements_npu.txt")

xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.23.post1')
clip_package = os.environ.get('CLIP_PACKAGE', "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip")
openclip_package = os.environ.get('OPENCLIP_PACKAGE', "https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip")
xformers_package = os.environ.get('XFORMERS_PACKAGE', 'xformers==0.0.26.post1')
clip_package = os.environ.get('CLIP_PACKAGE', "https://github.com/openai/CLIP/archive/a1d071733d7111c9c014f024669f959182114e33.zip")
openclip_package = os.environ.get('OPENCLIP_PACKAGE', "https://github.com/mlfoundations/open_clip/archive/9eaf2424e74a4e34f5041e640e5e69bac5eb41aa.zip")

assets_repo = os.environ.get('ASSETS_REPO', "https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git")
stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/Stability-AI/stablediffusion.git")
Expand Down
2 changes: 1 addition & 1 deletion modules/sd_disable_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_model_and_transforms_without_pretrained(*args, pretrained=None, **kwa
return self.create_model_and_transforms(*args, pretrained=None, **kwargs)

def CLIPTextModel_from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs):
res = self.CLIPTextModel_from_pretrained(None, *model_args, config=pretrained_model_name_or_path, state_dict={}, **kwargs)
res = self.CLIPTextModel_from_pretrained(pretrained_model_name_or_path, *model_args, config=pretrained_model_name_or_path, state_dict={}, **kwargs)
Copy link

@wolfschaf wolfschaf Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config=pretrained_model_name_or_path can be removed since it has the same behavior.

See: https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L3611
This is the only place where it is used as a string/path and in the next line it gets replaced anyway.

res.name_or_path = pretrained_model_name_or_path
return res

Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ lark
numpy
omegaconf
open-clip-torch
spandrel<0.3

piexif
psutil
pytorch_lightning
requests
resize-right
pydantic<2

safetensors
scikit-image>=0.19
tomesd
torch
torchdiffeq
torchsde
transformers==4.30.2
transformers==4.34.1
pillow-avif-plugin==1.4.3
65 changes: 33 additions & 32 deletions requirements_versions.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
GitPython==3.1.32
Pillow==9.5.0
accelerate==0.21.0
blendmodes==2022
clean-fid==0.1.35
diskcache==5.6.3
einops==0.4.1
facexlib==0.3.0
fastapi==0.94.0
gradio==3.41.2
httpcore==0.15
inflection==0.5.1
jsonmerge==1.8.0
kornia==0.6.7
lark==1.1.2
numpy==1.26.2
omegaconf==2.2.3
open-clip-torch==2.20.0
piexif==1.1.3
psutil==5.9.5
pytorch_lightning==1.9.4
resize-right==0.0.2
safetensors==0.4.2
scikit-image==0.21.0
spandrel==0.1.6
tomesd==0.1.3
torch
torchdiffeq==0.2.3
torchsde==0.2.6
transformers==4.30.2
httpx==0.24.1
pillow-avif-plugin==1.4.3
GitPython==3.1.43
Pillow==10.3.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if PIL is upgreaded to >= 10.0 then some things will have to be re-witten
for example

similar issues can exist in other dependencies
need lots of testing

accelerate==0.29.3
blendmodes==2024.1.1
clean-fid==0.1.35
diskcache==5.6.3
einops==0.8.0
facexlib==0.3.0
fastapi==0.90.1
gradio==3.41.2
httpcore==1.0.5
inflection==0.5.1
jsonmerge==1.9.2
kornia==0.7.2
lark==1.1.9
numpy==1.26.4
omegaconf==2.3.0
open-clip-torch==2.24.0
piexif==1.1.3
psutil==5.9.8
pydantic==1.10.15
pytorch-lightning==2.2.4
resize-right==0.0.2
safetensors==0.4.3
scikit-image==0.23.2
spandrel==0.2.2
tomesd==0.1.3
torch
torchdiffeq==0.2.3
torchsde==0.2.6
transformers==4.34.1
httpx==0.27.0
pillow-avif-plugin==1.4.3
2 changes: 1 addition & 1 deletion webui-macos-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

export install_dir="$HOME"
export COMMANDLINE_ARGS="--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate"
export TORCH_COMMAND="pip install torch==2.1.0 torchvision==0.16.0"
export TORCH_COMMAND="pip install torch==2.3.0 torchvision==0.18.0"
export PYTORCH_ENABLE_MPS_FALLBACK=1

####################################################################