better install shell based on issue comment

This commit is contained in:
wsl-wy
2023-08-08 00:45:59 +08:00
parent ad66116fe5
commit 92c5c47a4c
2 changed files with 77 additions and 42 deletions

View File

@@ -3,43 +3,73 @@
cd "$(dirname "$0")"
thisDir=$(pwd)
export INSTALL_DEPS=false
export INSTALL_FLASH_ATTN=false
declare -a PASS_THROUGH_ARGS=()
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
echo "Usage: $0 [-h|--help] [--install-deps] [--install-flash-attn]"
exit 0
;;
--install-deps)
export INSTALL_DEPS=true
shift
;;
--install-flash-attn)
export INSTALL_FLASH_ATTN=true
shift
;;
-)
shift
PASS_THROUGH_ARGS=($@)
break
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
echo "INSTALL_DEPS: $INSTALL_DEPS"
echo "INSTALL_FLASH_ATTN: $INSTALL_FLASH_ATTN"
echo "PASS_THROUGH_ARGS: ${PASS_THROUGH_ARGS[@]}"
function performInstall() {
set -e
pushd "$thisDir"
pip3 install -r requirements.txt
pip3 install gradio mdtex2html scipy
pip3 install gradio mdtex2html scipy argparse
if [[ ! -d flash-attention ]]; then
if ! git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention; then
echo "Clone flash-attention failed, please install it manually."
return 0
if $INSTALL_FLASH_ATTN; then
if [[ ! -d flash-attention ]]; then
if ! git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention; then
echo "Clone flash-attention failed, please install it manually."
return 0
fi
fi
cd flash-attention &&
pip3 install . &&
pip3 install csrc/layer_norm &&
pip3 install csrc/rotary ||
echo "Install flash-attention failed, please install it manually."
fi
cd flash-attention &&
pip3 install . &&
pip3 install csrc/layer_norm &&
pip3 install csrc/rotary ||
echo "Install flash-attention failed, please install it manually."
popd
}
echo "Starting WebUI..."
if ! python3 web_demo.py; then
echo "Run demo failed, install the deps and try again? (y/n)"
# auto perform install if in docker
if [[ -t 0 ]] && [[ -t 1 ]] && [[ ! -f "/.dockerenv" ]]; then
read doInstall
if ! python3 web_demo.py ${PASS_THROUGH_ARGS[@]}; then
if $INSTALL_DEPS; then
echo "Installing deps, and try again..."
performInstall && python3 web_demo.py ${PASS_THROUGH_ARGS[@]}
else
doInstall="y"
echo "Please install deps manually, or use --install-deps to install deps automatically."
fi
if ! [[ "$doInstall" =~ y|Y ]]; then
exit 1
fi
echo "Installing deps, and try again..."
performInstall && python3 web_demo.py
fi