install_env.bat 10 KB

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