webui.bat 2.1 KB

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