Skip to content

Commit

Permalink
Optional Accelerate Launch
Browse files Browse the repository at this point in the history
  • Loading branch information
d8ahazard committed Nov 9, 2022
1 parent ac08562 commit 0a54bd3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accelerate
basicsr
diffusers
fairscale==0.4.4
Expand Down
1 change: 1 addition & 0 deletions requirements_versions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
transformers==4.19.2
diffusers==0.3.0
accelerate==0.12.0
basicsr==1.4.2
gfpgan==1.3.8
gradio==3.9
Expand Down
1 change: 1 addition & 0 deletions webui-user.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=
set ACCELERATE=

call webui.bat
3 changes: 3 additions & 0 deletions webui-user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ export COMMANDLINE_ARGS=""
#export CODEFORMER_COMMIT_HASH=""
#export BLIP_COMMIT_HASH=""

# Uncomment to enable accelerated launch
#export ACCELERATE="True"

###########################################
13 changes: 13 additions & 0 deletions webui.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,28 @@ goto :show_stdout_stderr
:activate_venv
set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
echo venv %PYTHON%
if [%ACCELERATE%] == ["True"] goto :accelerate
goto :launch

:skip_venv

:accelerate
echo "Checking for accelerate"
dir %VENV_DIR%\Scripts\accelerate.exe >tmp/stdout.txt 2>tmp/stderr.txt
if %ERRORLEVEL% == 0 goto :accelerate_launch

:launch
%PYTHON% launch.py %*
pause
exit /b

:accelerate_launch
echo "Accelerating2"
set ACCELERATE="%~dp0%VENV_DIR%\Scripts\accelerate.exe"
%ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py
pause
exit /b

:show_stdout_stderr

echo.
Expand Down
16 changes: 12 additions & 4 deletions webui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,15 @@ else
exit 1
fi

printf "\n%s\n" "${delimiter}"
printf "Launching launch.py..."
printf "\n%s\n" "${delimiter}"
"${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ]
then
printf "\n%s\n" "${delimiter}"
printf "Accelerating launch.py..."
printf "\n%s\n" "${delimiter}"
accelerate launch --num_cpu_threads_per_process=6 "${LAUNCH_SCRIPT}" "$@"
else
printf "\n%s\n" "${delimiter}"
printf "Launching launch.py..."
printf "\n%s\n" "${delimiter}"
"${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
fi

0 comments on commit 0a54bd3

Please sign in to comment.