install_env.bat 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. @echo off
  2. chcp 65001
  3. set USE_MIRROR=true
  4. set INSTALL_TYPE=preview
  5. echo "USE_MIRROR: %USE_MIRROR%"
  6. echo "INSTALL_TYPE: %INSTALL_TYPE%"
  7. setlocal enabledelayedexpansion
  8. cd /D "%~dp0"
  9. set PATH="%PATH%";%SystemRoot%\system32
  10. echo %PATH%
  11. echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~\u4E00-\u9FFF ] " >nul && (
  12. echo.
  13. echo There are special characters in the current path, please make the path of fish-speech free of special characters before running. && (
  14. goto end
  15. )
  16. )
  17. set TMP=%CD%\fishenv
  18. set TEMP=%CD%\fishenv
  19. (call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
  20. set INSTALL_DIR=%cd%\fishenv
  21. set CONDA_ROOT_PREFIX=%cd%\fishenv\conda
  22. set INSTALL_ENV_DIR=%cd%\fishenv\env
  23. set PIP_CMD=%cd%\fishenv\env\python -m pip
  24. set PYTHON_CMD=%cd%\fishenv\env\python
  25. set API_FLAG_PATH=%~dp0API_FLAGS.txt
  26. set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
  27. if "!USE_MIRROR!" == "true" (
  28. set MINICONDA_DOWNLOAD_URL=https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
  29. )
  30. set MINICONDA_CHECKSUM=307194e1f12bbeb52b083634e89cc67db4f7980bd542254b43d3309eaf7cb358
  31. set conda_exists=F
  32. call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
  33. if "%ERRORLEVEL%" EQU "0" set conda_exists=T
  34. if "%conda_exists%" == "F" (
  35. echo.
  36. echo Downloading Miniconda...
  37. mkdir "%INSTALL_DIR%" 2>nul
  38. call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe"
  39. if errorlevel 1 (
  40. echo.
  41. echo Failed to download miniconda.
  42. goto end
  43. )
  44. for /f %%a in ('
  45. certutil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" sha256
  46. ^| find /i /v " "
  47. ^| find /i "%MINICONDA_CHECKSUM%"
  48. ') do (
  49. set "hash=%%a"
  50. )
  51. if not defined hash (
  52. echo.
  53. echo Miniconda hash mismatched!
  54. del "%INSTALL_DIR%\miniconda_installer.exe"
  55. goto end
  56. ) else (
  57. echo.
  58. echo Miniconda hash matched successfully.
  59. )
  60. echo Downloaded "%CONDA_ROOT_PREFIX%"
  61. start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%
  62. call "%CONDA_ROOT_PREFIX%\_conda.exe" --version
  63. if errorlevel 1 (
  64. echo.
  65. echo Cannot install Miniconda.
  66. goto end
  67. ) else (
  68. echo.
  69. echo Miniconda Install success.
  70. )
  71. del "%INSTALL_DIR%\miniconda_installer.exe"
  72. )
  73. if not exist "%INSTALL_ENV_DIR%" (
  74. echo.
  75. echo Creating Conda Environment...
  76. if "!USE_MIRROR!" == "true" (
  77. 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
  78. ) else (
  79. call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.10
  80. )
  81. if errorlevel 1 (
  82. echo.
  83. echo Failed to Create Environment.
  84. goto end
  85. )
  86. )
  87. if not exist "%INSTALL_ENV_DIR%\python.exe" (
  88. echo.
  89. echo Conda Env does not exist.
  90. goto end
  91. )
  92. set PYTHONNOUSERSITE=1
  93. set PYTHONPATH=
  94. set PYTHONHOME=
  95. set "CUDA_PATH=%INSTALL_ENV_DIR%"
  96. set "CUDA_HOME=%CUDA_PATH%"
  97. call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%"
  98. if errorlevel 1 (
  99. echo.
  100. echo Failed to activate Env.
  101. goto end
  102. ) else (
  103. echo.
  104. echo successfully create env.
  105. )
  106. set "packages=torch torchvision torchaudio openai-whisper fish-speech"
  107. if "!INSTALL_TYPE!" == "preview" (
  108. set "packages=!packages! triton_windows"
  109. )
  110. set "HF_ENDPOINT=https://huggingface.co"
  111. set "no_proxy="
  112. if "!USE_MIRROR!" == "true" (
  113. set "HF_ENDPOINT=https://hf-mirror.com"
  114. set "no_proxy=localhost, 127.0.0.1, 0.0.0.0"
  115. )
  116. echo "HF_ENDPOINT: !HF_ENDPOINT!"
  117. echo "NO_PROXY: !no_proxy!"
  118. set "install_packages="
  119. for %%p in (%packages%) do (
  120. %PIP_CMD% show %%p >nul 2>&1
  121. if errorlevel 1 (
  122. set "install_packages=!install_packages! %%p"
  123. )
  124. )
  125. if not "!install_packages!"=="" (
  126. echo.
  127. echo Installing: !install_packages!
  128. for %%p in (!install_packages!) do (
  129. if "!INSTALL_TYPE!"=="preview" (
  130. if "%%p"=="torch" (
  131. set "WHEEL_FILE=torch-2.4.0.dev20240427+cu121-cp310-cp310-win_amd64.whl"
  132. set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torch-2.4.0.dev20240427_cu121-cp310-cp310-win_amd64.whl?download=true"
  133. set "CHKSUM=b091308f4cb74e63d0323afd67c92f2279d9e488d8cbf467bcc7b939bcd74e0b"
  134. :TORCH_DOWNLOAD
  135. echo "%CD%\!WHEEL_FILE!"
  136. if not exist "%CD%\!WHEEL_FILE!" (
  137. call curl -Lk "!URL!" --output "!WHEEL_FILE!"
  138. )
  139. for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
  140. set "FILE_VALID=true"
  141. )
  142. if not defined FILE_VALID (
  143. echo File checksum does not match, re-downloading...
  144. del "!WHEEL_FILE!"
  145. goto TORCH_DOWNLOAD
  146. )
  147. echo "OK for !WHEEL_FILE!"
  148. %PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
  149. del "!WHEEL_FILE!"
  150. ) else if "%%p"=="torchvision" (
  151. set "WHEEL_FILE=torchvision-0.19.0.dev20240428+cu121-cp310-cp310-win_amd64.whl"
  152. set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torchvision-0.19.0.dev20240428_cu121-cp310-cp310-win_amd64.whl?download=true"
  153. set "CHKSUM=7e46d0a89534013f001563d15e80f9eb431089571720c51f2cc595feeb01d785"
  154. :TORCHVISION_DOWNLOAD
  155. if not exist "!WHEEL_FILE!" (
  156. call curl -Lk "!URL!" --output "!WHEEL_FILE!"
  157. )
  158. for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
  159. set "FILE_VALID=true"
  160. )
  161. if not defined FILE_VALID (
  162. echo File checksum does not match, re-downloading...
  163. del "!WHEEL_FILE!"
  164. goto TORCHVISION_DOWNLOAD
  165. )
  166. echo "OK for !WHEEL_FILE!"
  167. %PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
  168. del "!WHEEL_FILE!"
  169. ) else if "%%p"=="torchaudio" (
  170. set "WHEEL_FILE=torchaudio-2.2.0.dev20240427+cu121-cp310-cp310-win_amd64.whl"
  171. set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/torchaudio-2.2.0.dev20240427_cu121-cp310-cp310-win_amd64.whl?download=true"
  172. set "CHKSUM=abafb4bc82cbc6f58f18e1b95191bc1884c28e404781082db2eb540b4fae8a5d"
  173. :TORCHAUDIO_DOWNLOAD
  174. if not exist "!WHEEL_FILE!" (
  175. call curl -Lk "!URL!" --output "!WHEEL_FILE!"
  176. )
  177. for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
  178. set "FILE_VALID=true"
  179. )
  180. if not defined FILE_VALID (
  181. echo File checksum does not match, re-downloading...
  182. del "!WHEEL_FILE!"
  183. goto TORCHAUDIO_DOWNLOAD
  184. )
  185. echo "OK for !WHEEL_FILE!"
  186. %PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
  187. del "!WHEEL_FILE!"
  188. ) else if "%%p"=="openai-whisper" (
  189. %PIP_CMD% install openai-whisper --no-warn-script-location
  190. ) else if "%%p"=="fish-speech" (
  191. %PIP_CMD% install -e .
  192. ) else if "%%p"=="triton_windows" (
  193. set "WHEEL_FILE=triton_windows-0.1.0-py3-none-any.whl"
  194. set "URL=!HF_ENDPOINT!/datasets/SpicyqSama007/windows_compile/resolve/main/triton_windows-0.1.0-py3-none-any.whl?download=true"
  195. set "CHKSUM=2cc998638180f37cf5025ab65e48c7f629aa5a369176cfa32177d2bd9aa26a0a"
  196. :TRITON_DOWNLOAD
  197. if not exist "!WHEEL_FILE!" (
  198. call curl -Lk "!URL!" --output "!WHEEL_FILE!"
  199. )
  200. for /f "delims=" %%I in ('certutil -hashfile "!WHEEL_FILE!" SHA256 ^| find /i "!CHKSUM!"') do (
  201. set "FILE_VALID=true"
  202. )
  203. if not defined FILE_VALID (
  204. echo File checksum does not match, re-downloading...
  205. del "!WHEEL_FILE!"
  206. goto TRITON_DOWNLOAD
  207. )
  208. echo "OK for !WHEEL_FILE!"
  209. %PIP_CMD% install "%CD%\!WHEEL_FILE!" --no-warn-script-location
  210. del "!WHEEL_FILE!"
  211. )
  212. )
  213. )
  214. )
  215. set "install_packages="
  216. for %%p in (%packages%) do (
  217. %PIP_CMD% show %%p >nul 2>&1
  218. if errorlevel 1 (
  219. set "install_packages=!install_packages! %%p"
  220. )
  221. )
  222. if not "!install_packages!"=="" (
  223. echo.
  224. echo Installing: !install_packages!
  225. for %%p in (!install_packages!) do (
  226. if "!USE_MIRROR!"=="true" (
  227. if "%%p"=="torch" (
  228. %PIP_CMD% install torch --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
  229. ) else if "%%p"=="torchvision" (
  230. %PIP_CMD% install torchvision --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
  231. ) else if "%%p"=="torchaudio" (
  232. %PIP_CMD% install torchaudio --index-url https://mirror.sjtu.edu.cn/pytorch-wheels/cu121 --no-warn-script-location
  233. ) else if "%%p"=="openai-whisper" (
  234. %PIP_CMD% install -i https://pypi.tuna.tsinghua.edu.cn/simple openai-whisper --no-warn-script-location
  235. ) else if "%%p"=="fish-speech" (
  236. %PIP_CMD% install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
  237. )
  238. )
  239. if "!USE_MIRROR!"=="false" (
  240. if "%%p"=="torch" (
  241. %PIP_CMD% install torch --index-url https://download.pytorch.org/whl/cu121 --no-warn-script-location
  242. ) else if "%%p"=="torchvision" (
  243. %PIP_CMD% install torchvision --index-url https://download.pytorch.org/whl/cu121 --no-warn-script-location
  244. ) else if "%%p"=="torchaudio" (
  245. %PIP_CMD% install torchaudio --index-url https://download.pytorch.org/whl/cu121 --no-warn-script-location
  246. ) else if "%%p"=="openai-whisper" (
  247. %PIP_CMD% install openai-whisper --no-warn-script-location
  248. ) else if "%%p"=="fish-speech" (
  249. %PIP_CMD% install -e .
  250. )
  251. )
  252. )
  253. )
  254. echo Environment Check: Success.
  255. endlocal
  256. :end
  257. pause