forked from fishaudio/fish-speech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_env.bat
284 lines (250 loc) · 10.4 KB
/
install_env.bat
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
@echo off
chcp 65001
set USE_MIRROR=true
set INSTALL_TYPE=preview
echo "USE_MIRROR: %USE_MIRROR%"
echo "INSTALL_TYPE: %INSTALL_TYPE%"
setlocal enabledelayedexpansion
cd /D "%~dp0"
set PATH="%PATH%";%SystemRoot%\system32
echo %PATH%
echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~\u4E00-\u9FFF ] " >nul && (
echo.
echo There are special characters in the current path, please make the path of fish-speech free of special characters before running. && (
goto end
)
)
set TMP=%CD%\fishenv
set TEMP=%CD%\fishenv
(call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
set INSTALL_DIR=%cd%\fishenv
set CONDA_ROOT_PREFIX=%cd%\fishenv\conda
set INSTALL_ENV_DIR=%cd%\fishenv\env
set PIP_CMD=%cd%\fishenv\env\python -m pip
set PYTHON_CMD=%cd%\fishenv\env\python
set API_FLAG_PATH=%~dp0API_FLAGS.txt
set MINICONDA_DOWNLOAD_URL=https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
set MINICONDA_CHECKSUM=307194e1f12bbeb52b083634e89cc67db4f7980bd542254b43d3309eaf7cb358
set conda_exists=F
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
if "%ERRORLEVEL%" EQU "0" set conda_exists=T
if "%conda_exists%" == "F" (
echo.
echo Downloading Miniconda...
mkdir "%INSTALL_DIR%" 2>nul
call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe"
if errorlevel 1 (
echo.
echo Failed to download miniconda.
goto end
)
for /f %%a in ('
certutil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" sha256
^| find /i /v " "
^| find /i "%MINICONDA_CHECKSUM%"
') do (
set "hash=%%a"
)
if not defined hash (
echo.
echo Miniconda hash mismatched!
del "%INSTALL_DIR%\miniconda_installer.exe"
goto end
) else (
echo.
echo Miniconda hash matched successfully.
)
echo Downloaded "%CONDA_ROOT_PREFIX%"
start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version
if errorlevel 1 (
echo.
echo Cannot install Miniconda.
goto end
) else (
echo.
echo Miniconda Install success.
)
del "%INSTALL_DIR%\miniconda_installer.exe"
)
if not exist "%INSTALL_ENV_DIR%" (
echo.
echo Creating Conda Environment...
call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ python=3.10
if errorlevel 1 (
echo.
echo Failed to Create Environment.
goto end
)
)
if not exist "%INSTALL_ENV_DIR%\python.exe" (
echo.
echo Conda Env does not exist.
goto end
)
set PYTHONNOUSERSITE=1
set PYTHONPATH=
set PYTHONHOME=
set "CUDA_PATH=%INSTALL_ENV_DIR%"
set "CUDA_HOME=%CUDA_PATH%"
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
if errorlevel 1 (
echo.
echo Failed to activate Env.
goto end
) else (
echo.
echo successfully create env.
)
set "packages=torch torchvision torchaudio openai-whisper fish-speech"
if "!INSTALL_TYPE!" == "preview" (
set "packages=!packages! triton_windows"
)
set "HF_ENDPOINT=https://huggingface.co"
set "no_proxy="
if "!USE_MIRROR!" == "true" (
set "HF_ENDPOINT=https://hf-mirror.com"
set "no_proxy=localhost, 127.0.0.1, 0.0.0.0"
)
echo "HF_ENDPOINT: !HF_ENDPOINT!"
echo "NO_PROXY: !no_proxy!"
set "install_packages="
for %%p in (%packages%) do (
%PIP_CMD% show %%p >nul 2>&1
if errorlevel 1 (
set "install_packages=!install_packages! %%p"
)
)
if not "!install_packages!"=="" (
echo.
echo Installing: !install_packages!
for %%p in (!install_packages!) do (
if "!INSTALL_TYPE!"=="preview" (
if "%%p"=="torch" (
set "WHEEL_FILE=torch-2.4.0.dev20240427+cu121-cp310-cp310-win_amd64.whl"
set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torch-2.4.0.dev20240427_cu121-cp310-cp310-win_amd64.whl?download=true"
set "CHKSUM=b091308f4cb74e63d0323afd67c92f2279d9e488d8cbf467bcc7b939bcd74e0b"
:TORCH_DOWNLOAD
echo "%CD%\!WHEEL_FILE!"
if not exist "%CD%\!WHEEL_FILE!" (
call curl -Lk "!URL!" --output "!WHEEL_FILE!"
)
for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
set "FILE_VALID=true"
)
if not defined FILE_VALID (
echo File checksum does not match, re-downloading...
del "!WHEEL_FILE!"
goto TORCH_DOWNLOAD
)
echo "OK for !WHEEL_FILE!"
%PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
del "!WHEEL_FILE!"
) else if "%%p"=="torchvision" (
set "WHEEL_FILE=torchvision-0.19.0.dev20240428+cu121-cp310-cp310-win_amd64.whl"
set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torchvision-0.19.0.dev20240428_cu121-cp310-cp310-win_amd64.whl?download=true"
set "CHKSUM=7e46d0a89534013f001563d15e80f9eb431089571720c51f2cc595feeb01d785"
:TORCHVISION_DOWNLOAD
if not exist "!WHEEL_FILE!" (
call curl -Lk "!URL!" --output "!WHEEL_FILE!"
)
for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
set "FILE_VALID=true"
)
if not defined FILE_VALID (
echo File checksum does not match, re-downloading...
del "!WHEEL_FILE!"
goto TORCHVISION_DOWNLOAD
)
echo "OK for !WHEEL_FILE!"
%PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
del "!WHEEL_FILE!"
) else if "%%p"=="torchaudio" (
set "WHEEL_FILE=torchaudio-2.2.0.dev20240427+cu121-cp310-cp310-win_amd64.whl"
set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torchaudio-2.2.0.dev20240427_cu121-cp310-cp310-win_amd64.whl?download=true"
set "CHKSUM=abafb4bc82cbc6f58f18e1b95191bc1884c28e404781082db2eb540b4fae8a5d"
:TORCHAUDIO_DOWNLOAD
if not exist "!WHEEL_FILE!" (
call curl -Lk "!URL!" --output "!WHEEL_FILE!"
)
for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
set "FILE_VALID=true"
)
if not defined FILE_VALID (
echo File checksum does not match, re-downloading...
del "!WHEEL_FILE!"
goto TORCHAUDIO_DOWNLOAD
)
echo "OK for !WHEEL_FILE!"
%PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
del "!WHEEL_FILE!"
) else if "%%p"=="openai-whisper" (
%PIP_CMD% install openai-whisper --no-warn-script-location
) else if "%%p"=="fish-speech" (
%PIP_CMD% install -e .
) else if "%%p"=="triton_windows" (
set "WHEEL_FILE=triton_windows-0.1.0-py3-none-any.whl"
set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/triton_windows-0.1.0-py3-none-any.whl?download=true"
set "CHKSUM=2cc998638180f37cf5025ab65e48c7f629aa5a369176cfa32177d2bd9aa26a0a"
:TRITON_DOWNLOAD
if not exist "!WHEEL_FILE!" (
call curl -Lk "!URL!" --output "!WHEEL_FILE!"
)
for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
set "FILE_VALID=true"
)
if not defined FILE_VALID (
echo File checksum does not match, re-downloading...
del "!WHEEL_FILE!"
goto TRITON_DOWNLOAD
)
echo "OK for !WHEEL_FILE!"
%PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
del "!WHEEL_FILE!"
)
)
)
)
set "install_packages="
for %%p in (%packages%) do (
%PIP_CMD% show %%p >nul 2>&1
if errorlevel 1 (
set "install_packages=!install_packages! %%p"
)
)
if not "!install_packages!"=="" (
echo.
echo Installing: !install_packages!
for %%p in (!install_packages!) do (
if "!USE_MIRROR!"=="true" (
if "%%p"=="torch" (
%PIP_CMD% install torch --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
) else if "%%p"=="torchvision" (
%PIP_CMD% install torchvision --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
) else if "%%p"=="torchaudio" (
%PIP_CMD% install torchaudio --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
) else if "%%p"=="openai-whisper" (
%PIP_CMD% install -i https://pypi.tuna.tsinghua.edu.cn/simple openai-whisper --no-warn-script-location
) else if "%%p"=="fish-speech" (
%PIP_CMD% install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
)
)
if "!USE_MIRROR!"=="false" (
if "%%p"=="torch" (
%PIP_CMD% install torch --index-url https://download.pytorch.org/whl/nightly/cu121 --no-warn-script-location
) else if "%%p"=="torchvision" (
%PIP_CMD% install torchvision --index-url https://download.pytorch.org/whl/nightly/cu121 --no-warn-script-location
) else if "%%p"=="torchaudio" (
%PIP_CMD% install torchaudio --index-url https://download.pytorch.org/whl/nightly/cu121 --no-warn-script-location
) else if "%%p"=="openai-whisper" (
%PIP_CMD% install openai-whisper --no-warn-script-location
) else if "%%p"=="fish-speech" (
%PIP_CMD% install -e .
)
)
)
)
echo Environment Check: Success.
endlocal
:end
pause