Skip to content

Commit 4f0e1f5

Browse files
authored
Merge pull request #1018 from bmaltais/dev2
v21.7.10
2 parents 574079d + 084a9e8 commit 4f0e1f5

6 files changed

+139
-6
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ This will store a backup file with your current locally installed pip packages a
353353

354354
## Change History
355355

356+
* 2023/06/19 (v21.7.10)
357+
- Quick fix for linux GUI startup where it would try to install darwin requirements on top of linux. Ugly fix but work. Hopefulle some linux user will improve via a PR.
356358
* 2023/06/18 (v21.7.9)
357359
- Implement temporary fix for validation of image dataset. Will no longer stop execution but will let training continue... this is changed to avoid stopping training on false positive... yet still raise awaireness that something might be wrong with the image dataset structure.
358360
* 2023/06/14 (v21.7.8)

gui.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ cd "$SCRIPT_DIR"
1717
source "$SCRIPT_DIR/venv/bin/activate"
1818

1919
# If the requirements are validated, run the kohya_gui.py script with the command-line arguments
20-
if python "$SCRIPT_DIR"/tools/validate_requirements.py -r "$SCRIPT_DIR"/requirements_unix.txt; then
20+
if python "$SCRIPT_DIR"/tools/validate_requirements_unix.py -r "$SCRIPT_DIR"/requirements_unix.txt; then
2121
python "$SCRIPT_DIR/kohya_gui.py" "$@"
2222
fi

library/common_gui.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def run_cmd_advanced_training(**kwargs):
12871287
return run_cmd
12881288

12891289
def verify_image_folder_pattern(folder_path):
1290-
false_response = True # temporarilly set to true to prevent stopping training in case of false positive
1290+
false_response = True # temporarily set to true to prevent stopping training in case of false positive
12911291
true_response = True
12921292

12931293
# Check if the folder exists

requirements_Ubuntu_20.04.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
accelerate==0.19.0
2+
albumentations==1.3.0
3+
altair==4.2.2
4+
bitsandbytes==0.35.0
5+
dadaptation==3.1
6+
diffusers[torch]==0.10.2
7+
easygui==0.98.3
8+
einops==0.6.0
9+
fairscale==0.4.13
10+
ftfy==6.1.1
11+
gradio==3.23.0; sys_platform == 'darwin'
12+
gradio==3.32.0; sys_platform != 'darwin'
13+
huggingface-hub==0.13.3; sys_platform == 'darwin'
14+
huggingface-hub==0.13.3; sys_platform != 'darwin'
15+
lion-pytorch==0.0.6
16+
lycoris_lora==0.1.6
17+
opencv-python==4.7.0.68
18+
prodigyopt==1.0
19+
pytorch-lightning==1.9.0
20+
rich==13.4.1
21+
safetensors==0.2.6
22+
tensorboard==2.10.1 ; sys_platform != 'darwin'
23+
tensorboard==2.12.1 ; sys_platform == 'darwin'
24+
tensorflow==2.10.1; sys_platform != 'darwin'
25+
timm==0.6.12
26+
tk==0.1.0
27+
toml==0.10.2
28+
transformers==4.26.0
29+
voluptuous==0.13.1
30+
wandb==0.15.0
31+
# for kohya_ss library
32+
.

requirements_unix.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
accelerate==0.19.0
1+
accelerate==0.15.0
22
albumentations==1.3.0
33
altair==4.2.2
44
bitsandbytes==0.35.0
@@ -10,12 +10,11 @@ fairscale==0.4.13
1010
ftfy==6.1.1
1111
gradio==3.23.0; sys_platform == 'darwin'
1212
gradio==3.32.0; sys_platform != 'darwin'
13-
huggingface-hub==0.13.3; sys_platform == 'darwin'
13+
huggingface-hub==0.13.0; sys_platform == 'darwin'
1414
huggingface-hub==0.13.3; sys_platform != 'darwin'
1515
lion-pytorch==0.0.6
1616
lycoris_lora==0.1.6
1717
opencv-python==4.7.0.68
18-
prodigyopt==1.0
1918
pytorch-lightning==1.9.0
2019
rich==13.4.1
2120
safetensors==0.2.6
@@ -29,4 +28,4 @@ transformers==4.26.0
2928
voluptuous==0.13.1
3029
wandb==0.15.0
3130
# for kohya_ss library
32-
.
31+
.

tools/validate_requirements_unix.py

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import os
2+
import re
3+
import sys
4+
import shutil
5+
import argparse
6+
import subprocess
7+
from setup_windows import check_repo_version
8+
9+
# Get the absolute path of the current file's directory (Kohua_SS project directory)
10+
project_directory = os.path.dirname(os.path.abspath(__file__))
11+
12+
# Check if the "tools" directory is present in the project_directory
13+
if "tools" in project_directory:
14+
# If the "tools" directory is present, move one level up to the parent directory
15+
project_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16+
17+
# Add the project directory to the beginning of the Python search path
18+
sys.path.insert(0, project_directory)
19+
20+
from library.custom_logging import setup_logging
21+
22+
# Set up logging
23+
log = setup_logging()
24+
25+
26+
def check_torch():
27+
# Check for nVidia toolkit or AMD toolkit
28+
if shutil.which('nvidia-smi') is not None or os.path.exists(
29+
os.path.join(
30+
os.environ.get('SystemRoot') or r'C:\Windows',
31+
'System32',
32+
'nvidia-smi.exe',
33+
)
34+
):
35+
log.info('nVidia toolkit detected')
36+
elif shutil.which('rocminfo') is not None or os.path.exists(
37+
'/opt/rocm/bin/rocminfo'
38+
):
39+
log.info('AMD toolkit detected')
40+
else:
41+
log.info('Using CPU-only Torch')
42+
43+
try:
44+
import torch
45+
46+
log.info(f'Torch {torch.__version__}')
47+
48+
# Check if CUDA is available
49+
if not torch.cuda.is_available():
50+
log.warning('Torch reports CUDA not available')
51+
else:
52+
if torch.version.cuda:
53+
# Log nVidia CUDA and cuDNN versions
54+
log.info(
55+
f'Torch backend: nVidia CUDA {torch.version.cuda} cuDNN {torch.backends.cudnn.version() if torch.backends.cudnn.is_available() else "N/A"}'
56+
)
57+
elif torch.version.hip:
58+
# Log AMD ROCm HIP version
59+
log.info(f'Torch backend: AMD ROCm HIP {torch.version.hip}')
60+
else:
61+
log.warning('Unknown Torch backend')
62+
63+
# Log information about detected GPUs
64+
for device in [
65+
torch.cuda.device(i) for i in range(torch.cuda.device_count())
66+
]:
67+
log.info(
68+
f'Torch detected GPU: {torch.cuda.get_device_name(device)} VRAM {round(torch.cuda.get_device_properties(device).total_memory / 1024 / 1024)} Arch {torch.cuda.get_device_capability(device)} Cores {torch.cuda.get_device_properties(device).multi_processor_count}'
69+
)
70+
return int(torch.__version__[0])
71+
except Exception as e:
72+
log.error(f'Could not load torch: {e}')
73+
sys.exit(1)
74+
75+
76+
def install_requirements(requirements_file):
77+
log.info('Verifying requirements')
78+
subprocess.run(f'"{sys.executable}" -m pip install -U -r "{requirements_file}"', shell=True, check=False, env=os.environ)
79+
80+
81+
def main():
82+
check_repo_version()
83+
# Parse command line arguments
84+
parser = argparse.ArgumentParser(
85+
description='Validate that requirements are satisfied.'
86+
)
87+
parser.add_argument(
88+
'-r',
89+
'--requirements',
90+
type=str,
91+
help='Path to the requirements file.',
92+
)
93+
parser.add_argument('--debug', action='store_true', help='Debug on')
94+
args = parser.parse_args()
95+
96+
install_requirements(args.requirements)
97+
98+
99+
if __name__ == '__main__':
100+
main()

0 commit comments

Comments
 (0)