webui.bat 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. @echo off
  2. if not defined PYTHON (set PYTHON=python)
  3. if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")
  4. set SD_WEBUI_RESTART=tmp/restart
  5. set ERROR_REPORTING=FALSE
  6. mkdir tmp 2>NUL
  7. %PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
  8. if %ERRORLEVEL% == 0 goto :check_pip
  9. echo Couldn't launch python
  10. goto :show_stdout_stderr
  11. :check_pip
  12. %PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
  13. if %ERRORLEVEL% == 0 goto :start_venv
  14. if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr
  15. %PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt
  16. if %ERRORLEVEL% == 0 goto :start_venv
  17. echo Couldn't install pip
  18. goto :show_stdout_stderr
  19. :start_venv
  20. if ["%VENV_DIR%"] == ["-"] goto :skip_venv
  21. if ["%SKIP_VENV%"] == ["1"] goto :skip_venv
  22. dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt
  23. if %ERRORLEVEL% == 0 goto :activate_venv
  24. for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
  25. echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
  26. %PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt
  27. if %ERRORLEVEL% == 0 goto :activate_venv
  28. echo Unable to create venv in directory "%VENV_DIR%"
  29. goto :show_stdout_stderr
  30. :activate_venv
  31. set PYTHON="%VENV_DIR%\Scripts\Python.exe"
  32. echo venv %PYTHON%
  33. :skip_venv
  34. if [%ACCELERATE%] == ["True"] goto :accelerate
  35. goto :launch
  36. :accelerate
  37. echo Checking for accelerate
  38. set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe"
  39. if EXIST %ACCELERATE% goto :accelerate_launch
  40. :launch
  41. %PYTHON% launch.py %*
  42. if EXIST tmp/restart goto :skip_venv
  43. pause
  44. exit /b
  45. :accelerate_launch
  46. echo Accelerating
  47. %ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py
  48. if EXIST tmp/restart goto :skip_venv
  49. pause
  50. exit /b
  51. :show_stdout_stderr
  52. echo.
  53. echo exit code: %errorlevel%
  54. for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
  55. if %size% equ 0 goto :show_stderr
  56. echo.
  57. echo stdout:
  58. type tmp\stdout.txt
  59. :show_stderr
  60. for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
  61. if %size% equ 0 goto :show_stderr
  62. echo.
  63. echo stderr:
  64. type tmp\stderr.txt
  65. :endofscript
  66. echo.
  67. echo Launch unsuccessful. Exiting.
  68. pause