forked from rsxdalv/tts-generation-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
102 lines (84 loc) · 3.28 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import subprocess
def do(cmd): # https://stackoverflow.com/a/62986640
try:
run = subprocess.run(cmd, shell=True)
run.check_returncode()
return run
except subprocess.CalledProcessError as e:
try:
print(
e.stderr.decode().strip(),
e.returncode,
)
except Exception:
print(e)
pass
raise e
def try_install(requirements, name=None):
try:
print(f"Installing {name or requirements} dependencies...")
do(f"pip install {requirements} torch==2.3.1")
print(f"Successfully installed {name or requirements} dependencies")
except Exception:
print(f"Failed to install {name or requirements} dependencies")
def is_node_installed():
try:
print("Checking if node is installed...")
do("node --version")
return True
except Exception:
print("Node is not installed, skipping node_modules setup")
return False
def setup_node_modules():
try:
print("Installing node_modules...")
do("cd react-ui && npm install")
print("Successfully installed node_modules")
print("Building react-ui...")
do("cd react-ui && npm run build")
print("Successfully built react-ui")
except Exception:
print("Failed to install node_modules")
def check_if_torch_has_cuda():
try:
print("Checking if torch has CUDA...")
do("python check_cuda.py")
return True
except Exception:
return False
def main():
print("Legacy installer is almost guaranteed to break installation, including torch+cuda")
print("For this reason, it is disabled")
print("It is recommended to use the new installer in a new directory, and leave the existing installation intact")
print("The new installer can be downloaded from https://github.com/rsxdalv/tts-generation-webui/")
if input("Do you still want to risk upgrading? [y/N] ").lower() != "y":
print("Skipping dependencies update")
return
print("Updating dependencies... (legacy installer, might break)")
try_install("-r requirements.txt", "Core Packages, Bark, Tortoise")
try_install(
"xformers==0.0.27 --index-url https://download.pytorch.org/whl/cu118",
"xformers",
)
try_install("-r requirements_bark_hubert_quantizer.txt", "Bark Voice Clone")
try_install("-r requirements_rvc.txt", "RVC")
try_install("-r requirements_audiocraft.txt", "Audiocraft")
try_install("-r requirements_styletts2.txt", "StyleTTS")
try_install("-r requirements_vall_e.txt", "Vall-E-X")
try_install("-r requirements_maha_tts.txt", "Maha TTS")
try_install("-r requirements_stable_audio.txt", "Stable Audio")
# reinstall hydra-core==1.3.2 because of fairseq
try_install("hydra-core==1.3.2", "hydra-core fix due to fairseq")
if is_node_installed():
setup_node_modules()
if check_if_torch_has_cuda():
print("Torch has CUDA, skipping reinstall")
else:
print(
"Torch does not have CUDA, assuming CPU mode, installing CPU version of PyTorch"
)
do(
"conda install --force-reinstall -y -k pytorch torchvision torchaudio cpuonly -c pytorch"
)
if __name__ == "__main__":
main()