Linaqruf / kohya-trainer

Adapted from https://note.com/kohya_ss/n/nbf7ce8d80f29 for easier cloning
Apache License 2.0
1.82k stars 294 forks source link

torchaudio、torchtext 、torchvision、 torch2.1.0 #348

Open Copynoa opened 3 months ago

Copynoa commented 3 months ago

I found the problem of incompatibility between torchaudio, torchtext and torchvision and torch2.1.0 version i try run this code to update torch=2.2.1 before install Kohya Trainer,

!pip uninstall -y torch !pip install torch==2.2.1

import torchbut it still do back 2.1.0 when i run install Kohya Trainer, because !pip install -q xformers==0.0.22.post7 This version of xformers requires torch==2.1.0, so when running this command, pip will automatically downgrade your torch version to 2.1.0 to satisfy xformers' dependency requirements,

so,,,,I hope the author will quickly update the version of xformers that is compatible with torch==2.2.1 or found the versions of the three libraries torchaudio, torchtext and torchvision match the current torch2.1.0

younyokel commented 3 months ago

+1

FozeAhmad9999 commented 3 months ago

+1

FozeAhmad9999 commented 3 months ago

any fixes yet ?

younyokel commented 3 months ago

any fixes yet ?

Check the issue after this one, there's a temporary fix

FozeAhmad9999 commented 3 months ago

thank you

JonesHong commented 3 months ago

I've successfully fixed the library requirements, and it worked for me. Here is my code. Go to 1.1 edit it!

def install_dependencies(verbose=True, install_xformers=True):
    import os
    from subprocess import getoutput

    s = getoutput('nvidia-smi')

    # Adjust the CUDA version according to the NVIDIA GPU model
    if 'T4' in s:
        !sed -i "s@cpu@cuda@" library/model_util.py

    # Update the handling of requirements.txt to directly install all dependencies
    # including newly added packages such as bitsandbytes and pytorch-lightning
    # !pip install {'-q' if not verbose else ''} --upgrade -r requirements.txt

    # Install TensorFlow
    !pip install {'-q' if not verbose else ''} tensorflow==2.15.0

    # Update PyTorch and related package installation commands according to the new requirements.txt
    # Note, we are using PyTorch 2.1.0 and the specified CUDA version cu121
    # and updating torchtext to a version compatible with it, which is 0.16.0
    !pip install {'-q' if not verbose else ''} torch==2.1.0+cu121 torchvision==0.16.0 \
     torchaudio==2.1.0+cu121 torchtext==0.16.0 --extra-index-url https://download.pytorch.org/whl/cu121 -U

    # Install other dependencies
    !pip install {'-q' if not verbose else ''} --upgrade \
        accelerate==0.15.0 \
        diffusers==0.10.0 \
        transformers==4.26.0 \
        opencv-python==4.7.0.68 \
        bitsandbytes==0.40.0.post4 \
        pytorch-lightning==1.9.0 \
        albumentations==1.3.1 \
        voluptuous==0.13.1 \
        safetensors==0.4.2 \
        einops==0.6.0 \
        toml==0.10.2 \
        ftfy==6.1.1 \
        lion_pytorch==0.0.6 \
        dadaptation==3.1 \
        prodigyopt==1.0 \
        lycoris_lora==0.1.4

    # Conditionally install xformers, version updated to 0.0.22.post7
    if install_xformers:
        !pip install {'-q' if not verbose else ''} xformers==0.0.22.post7 triton==2.1.0 -U

    # Check if the accelerate configuration file exists, if not, create it
    from accelerate.utils import write_basic_config

    if not os.path.exists(accelerate_config):
        write_basic_config(save_location=accelerate_config)  
(...)
cosmicoxytocin commented 3 months ago

Use This for the time being. I will work at updating dependencies tomorrow unless Linaqruf updates the repo first.