install_env.bat 10 KB

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