MonsterMMORPG commited on
Commit
15b485a
1 Parent(s): 8669eb0

Upload kohua_gui_pass_update.sh

Browse files
Files changed (1) hide show
  1. kohua_gui_pass_update.sh +123 -0
kohua_gui_pass_update.sh ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ # Checks to see if variable is set and non-empty.
4
+ # This is defined first, so we can use the function for some default variable values
5
+ env_var_exists() {
6
+ if [[ -n "${!1}" ]]; then
7
+ return 0
8
+ else
9
+ return 1
10
+ fi
11
+ }
12
+
13
+ # Define the directory path for WSL2
14
+ lib_path="/usr/lib/wsl/lib/"
15
+
16
+ # Check if the directory exists
17
+ if [ -d "$lib_path" ]; then
18
+ # Check if LD_LIBRARY_PATH is already set
19
+ if [ -z "${LD_LIBRARY_PATH}" ]; then
20
+ # LD_LIBRARY_PATH is not set, set it to the lib_path
21
+ export LD_LIBRARY_PATH="$lib_path"
22
+ # echo "LD_LIBRARY_PATH set to: $LD_LIBRARY_PATH"
23
+ fi
24
+ fi
25
+
26
+ # Need RUNPOD to have a default value before first access
27
+ RUNPOD=false
28
+ if env_var_exists RUNPOD_POD_ID || env_var_exists RUNPOD_API_KEY; then
29
+ RUNPOD=true
30
+ fi
31
+
32
+ # If it is run with the sudo command, get the complete LD_LIBRARY_PATH environment variable of the system and assign it to the current environment,
33
+ # because it will be used later.
34
+ if [ -n "$SUDO_USER" ] || [ -n "$SUDO_COMMAND" ]; then
35
+ echo "The sudo command resets the non-essential environment variables, we keep the LD_LIBRARY_PATH variable."
36
+ export LD_LIBRARY_PATH=$(sudo -i printenv LD_LIBRARY_PATH)
37
+ fi
38
+
39
+ # This gets the directory the script is run from so pathing can work relative to the script where needed.
40
+ SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
41
+
42
+ # Step into GUI local directory
43
+ cd "$SCRIPT_DIR" || exit 1
44
+
45
+ if [ -d "$SCRIPT_DIR/venv" ]; then
46
+ source "$SCRIPT_DIR/venv/bin/activate" || exit 1
47
+ else
48
+ echo "venv folder does not exist. Not activating..."
49
+ fi
50
+
51
+ # Check if LD_LIBRARY_PATH environment variable exists
52
+ if [[ -z "${LD_LIBRARY_PATH}" ]]; then
53
+ # Set the ANSI escape sequence for yellow text
54
+ YELLOW='\033[0;33m'
55
+ # Set the ANSI escape sequence to reset text color
56
+ RESET='\033[0m'
57
+
58
+ echo -e "${YELLOW}Warning: LD_LIBRARY_PATH environment variable is not set.${RESET}"
59
+ echo -e "${YELLOW}Certain functionalities may not work correctly.${RESET}"
60
+ echo -e "${YELLOW}Please ensure that the required libraries are properly configured.${RESET}"
61
+ echo -e " "
62
+ echo -e "${YELLOW}If you use WSL2 you may want to: export LD_LIBRARY_PATH=/usr/lib/wsl/lib/${RESET}"
63
+ echo -e " "
64
+ fi
65
+
66
+ # Determine the requirements file based on the system
67
+ if [[ "$OSTYPE" == "darwin"* ]]; then
68
+ if [[ "$(uname -m)" == "arm64" ]]; then
69
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_macos_arm64.txt"
70
+ else
71
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_macos_amd64.txt"
72
+ fi
73
+ else
74
+ if [ "$RUNPOD" = false ]; then
75
+ if [[ "$@" == *"--use-ipex"* ]]; then
76
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_linux_ipex.txt"
77
+ elif [[ "$@" == *"--use-rocm"* ]] || [ -x "$(command -v rocminfo)" ] || [ -f "/opt/rocm/bin/rocminfo" ]; then
78
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_linux_rocm.txt"
79
+ else
80
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_linux.txt"
81
+ fi
82
+ else
83
+ REQUIREMENTS_FILE="$SCRIPT_DIR/requirements_runpod.txt"
84
+ fi
85
+ fi
86
+
87
+ #Set OneAPI if it's not set by the user
88
+ if [[ "$@" == *"--use-ipex"* ]]
89
+ then
90
+ if [ -d "$SCRIPT_DIR/venv" ] && [[ -z "${DISABLE_VENV_LIBS}" ]]; then
91
+ export LD_LIBRARY_PATH=$(realpath "$SCRIPT_DIR/venv")/lib/:$LD_LIBRARY_PATH
92
+ fi
93
+ export NEOReadDebugKeys=1
94
+ export ClDeviceGlobalMemSizeAvailablePercent=100
95
+ if [[ ! -z "${IPEXRUN}" ]] && [ ${IPEXRUN}="True" ] && [ -x "$(command -v ipexrun)" ]
96
+ then
97
+ if [[ -z "$STARTUP_CMD" ]]
98
+ then
99
+ STARTUP_CMD=ipexrun
100
+ fi
101
+ if [[ -z "$STARTUP_CMD_ARGS" ]]
102
+ then
103
+ STARTUP_CMD_ARGS="--multi-task-manager taskset --memory-allocator tcmalloc"
104
+ fi
105
+ fi
106
+ fi
107
+
108
+ #Set STARTUP_CMD as normal python if not specified
109
+ if [[ -z "$STARTUP_CMD" ]]
110
+ then
111
+ STARTUP_CMD=python
112
+ fi
113
+
114
+ # Commented out requirements verification
115
+ # if python "$SCRIPT_DIR/setup/validate_requirements.py" -r "$REQUIREMENTS_FILE"; then
116
+ # "${STARTUP_CMD}" $STARTUP_CMD_ARGS "$SCRIPT_DIR/kohya_gui.py" "$@"
117
+ # else
118
+ # echo "Validation failed. Exiting..."
119
+ # exit 1
120
+ # fi
121
+
122
+ # Start the script directly
123
+ "${STARTUP_CMD}" $STARTUP_CMD_ARGS "$SCRIPT_DIR/kohya_gui.py" "$@"