2022-09-02 00:49:35 -06:00
|
|
|
@echo off
|
|
|
|
|
2023-10-14 06:58:28 -06:00
|
|
|
if exist webui.settings.bat (
|
|
|
|
call webui.settings.bat
|
|
|
|
)
|
|
|
|
|
2022-09-08 23:37:19 -06:00
|
|
|
if not defined PYTHON (set PYTHON=python)
|
2023-09-13 06:20:01 -06:00
|
|
|
if defined GIT (set "GIT_PYTHON_GIT_EXECUTABLE=%GIT%")
|
2023-01-15 13:13:58 -07:00
|
|
|
if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")
|
2022-09-08 03:18:50 -06:00
|
|
|
|
2023-06-05 11:04:28 -06:00
|
|
|
set SD_WEBUI_RESTART=tmp/restart
|
2022-09-26 04:52:44 -06:00
|
|
|
set ERROR_REPORTING=FALSE
|
|
|
|
|
2022-09-02 00:49:35 -06:00
|
|
|
mkdir tmp 2>NUL
|
|
|
|
|
|
|
|
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
|
2023-01-24 14:49:16 -07:00
|
|
|
if %ERRORLEVEL% == 0 goto :check_pip
|
2022-09-02 00:49:35 -06:00
|
|
|
echo Couldn't launch python
|
|
|
|
goto :show_stdout_stderr
|
|
|
|
|
2023-01-24 14:49:16 -07:00
|
|
|
:check_pip
|
|
|
|
%PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
|
|
|
|
if %ERRORLEVEL% == 0 goto :start_venv
|
|
|
|
if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr
|
|
|
|
%PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt
|
|
|
|
if %ERRORLEVEL% == 0 goto :start_venv
|
|
|
|
echo Couldn't install pip
|
|
|
|
goto :show_stdout_stderr
|
|
|
|
|
2022-09-13 07:48:18 -06:00
|
|
|
:start_venv
|
2023-01-10 15:27:00 -07:00
|
|
|
if ["%VENV_DIR%"] == ["-"] goto :skip_venv
|
2023-01-24 11:13:05 -07:00
|
|
|
if ["%SKIP_VENV%"] == ["1"] goto :skip_venv
|
2022-09-02 10:26:18 -06:00
|
|
|
|
2023-01-10 15:27:00 -07:00
|
|
|
dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt
|
2022-09-02 10:26:18 -06:00
|
|
|
if %ERRORLEVEL% == 0 goto :activate_venv
|
|
|
|
|
2022-09-02 16:55:56 -06:00
|
|
|
for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
|
2022-09-02 10:26:18 -06:00
|
|
|
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
|
2023-01-10 15:27:00 -07:00
|
|
|
%PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt
|
2024-05-09 15:16:53 -06:00
|
|
|
if %ERRORLEVEL% == 0 goto :upgrade_pip
|
2023-01-10 15:27:00 -07:00
|
|
|
echo Unable to create venv in directory "%VENV_DIR%"
|
2022-09-02 10:26:18 -06:00
|
|
|
goto :show_stdout_stderr
|
|
|
|
|
2024-05-09 15:16:53 -06:00
|
|
|
:upgrade_pip
|
|
|
|
"%VENV_DIR%\Scripts\Python.exe" -m pip install --upgrade pip
|
|
|
|
if %ERRORLEVEL% == 0 goto :activate_venv
|
|
|
|
echo Warning: Failed to upgrade PIP version
|
|
|
|
|
2022-09-02 10:26:18 -06:00
|
|
|
:activate_venv
|
2023-01-10 12:26:49 -07:00
|
|
|
set PYTHON="%VENV_DIR%\Scripts\Python.exe"
|
2024-07-18 08:49:49 -06:00
|
|
|
call "%VENV_DIR%\Scripts\activate.bat"
|
2022-09-02 10:26:18 -06:00
|
|
|
echo venv %PYTHON%
|
|
|
|
|
|
|
|
:skip_venv
|
2023-01-24 11:13:05 -07:00
|
|
|
if [%ACCELERATE%] == ["True"] goto :accelerate
|
|
|
|
goto :launch
|
2022-09-07 03:32:28 -06:00
|
|
|
|
2022-11-09 10:15:17 -07:00
|
|
|
:accelerate
|
2023-01-24 11:13:05 -07:00
|
|
|
echo Checking for accelerate
|
2023-01-10 12:26:49 -07:00
|
|
|
set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe"
|
2022-11-10 08:39:43 -07:00
|
|
|
if EXIST %ACCELERATE% goto :accelerate_launch
|
2022-11-09 10:15:17 -07:00
|
|
|
|
2022-09-02 00:49:35 -06:00
|
|
|
:launch
|
2022-10-09 18:52:35 -06:00
|
|
|
%PYTHON% launch.py %*
|
2023-06-03 00:59:56 -06:00
|
|
|
if EXIST tmp/restart goto :skip_venv
|
2022-09-02 00:49:35 -06:00
|
|
|
pause
|
|
|
|
exit /b
|
|
|
|
|
2022-11-09 10:15:17 -07:00
|
|
|
:accelerate_launch
|
2023-01-24 14:49:16 -07:00
|
|
|
echo Accelerating
|
2022-11-09 10:15:17 -07:00
|
|
|
%ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py
|
2023-06-03 00:59:56 -06:00
|
|
|
if EXIST tmp/restart goto :skip_venv
|
2022-11-09 10:15:17 -07:00
|
|
|
pause
|
|
|
|
exit /b
|
|
|
|
|
2022-09-02 00:49:35 -06:00
|
|
|
:show_stdout_stderr
|
|
|
|
|
|
|
|
echo.
|
|
|
|
echo exit code: %errorlevel%
|
|
|
|
|
|
|
|
for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
|
|
|
|
if %size% equ 0 goto :show_stderr
|
|
|
|
echo.
|
|
|
|
echo stdout:
|
|
|
|
type tmp\stdout.txt
|
|
|
|
|
|
|
|
:show_stderr
|
|
|
|
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
|
|
|
|
if %size% equ 0 goto :show_stderr
|
|
|
|
echo.
|
|
|
|
echo stderr:
|
|
|
|
type tmp\stderr.txt
|
|
|
|
|
|
|
|
:endofscript
|
|
|
|
|
|
|
|
echo.
|
|
|
|
echo Launch unsuccessful. Exiting.
|
2022-09-02 10:26:18 -06:00
|
|
|
pause
|