release v1.1.0

This commit is contained in:
will.yang
2024-10-10 20:25:23 +08:00
parent 92fce84bdd
commit 71773f050a
28 changed files with 1717 additions and 650 deletions

View File

@@ -1,61 +1,110 @@
#!/bin/bash
#*****************************************************************************************#
# 该脚本为 RKLLM-Server-Flask 服务的一键设置脚本
# 用户可以运行该脚本实现Linux板端的 RKLLM-Server-Flask 服务的自动化部署。
# 使用说明: ./build_rkllm_server_flask.sh [目标平台:rk3588/rk3576] [RKLLM-Server工作路径] [已转换的rkllm模型在板端的绝对路径]
# example: ./build_rkllm_server_flask.sh rk3588 /user/data/rkllm_server /user/data/rkllm_server/model.rkllm
# This script is an automated setup script for the RKLLM-Server-Flask service.
# Users can run this script to automate the deployment of the RKLLM-Server-Flask service on a Linux board.
# Usage: ./build_rkllm_server_flask.sh --workshop [RKLLM-Server Working Path] --model_path [Absolute Path of Converted RKLLM Model on Board] --platform [Target Platform: rk3588/rk3576] --npu_num [NPU Core Count] [--lora_model_path [Lora Model Path]] [--prompt_cache_path [Prompt Cache File Path]]
# example: ./build_rkllm_server_flask.sh --workshop /user/data --model_path /user/data/model.rkllm --platform rk3588 --npu_num 3
#*****************************************************************************************#
#################### 检查板端是否已经安装了 pip/gradio 库 ####################
# 1.准备板端的gradio环境
LORA_PATH=""
PROMPT_FILE_PATH=""
# Function to display help
function show_help {
echo "Usage: ./build_rkllm_server_flask.sh --workshop [RKLLM-Server Working Path] --model_path [Absolute Path of Converted RKLLM Model on Board] --platform [Target Platform: rk3588/rk3576] --npu_num [NPU Core Count] [--lora_path [Lora Model Path]] [--prompt_cache_path [Prompt Cache File Path]]"
}
# Parse command-line options
while [[ $# -gt 0 ]]; do
case "$1" in
--workshop)
WORKING_PATH="$2"
shift 2
;;
--model_path)
MODEL_PATH="$2"
shift 2
;;
--platform)
TARGET_PLATFORM="$2"
shift 2
;;
--npu_num)
NPU_CORE_COUNT="$2"
shift 2
;;
--lora_model_path)
LORA_PATH="$2"
shift 2
;;
--prompt_cache_path)
PROMPT_FILE_PATH="$2"
shift 2
;;
--help)
show_help
exit 0
;;
*)
echo "无效的选项: $1" 1>&2
show_help
exit 1
;;
esac
done
#################### Check if pip and the Flask library are already installed on the board. ####################
adb shell << EOF
# 检查是否安装了 pip3
if ! command -v pip3 &> /dev/null; then
echo "-------- pip3 未安装,将进行安装... --------"
# 安装 pip3
echo "-------- pip3 is not installed. Installing it now... --------"
sudo apt update
sudo apt install python3-pip -y
else
echo "-------- pip3 已经安装 --------"
echo "-------- pip3 is already installed. --------"
fi
# 检查是否安装了 flask
if ! python3 -c "import flask" &> /dev/null; then
echo "-------- flask 未安装,将进行安装... --------"
echo "-------- flask is not installed. Installing it now... --------"
# 安装 flask
pip install flask==2.2.2 Werkzeug==2.2.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install flask==2.2.2 Werkzeug==2.2.2 -i https://pypi.tuna.tsinghua.edu.cn/simple --break-system-packages
else
echo "-------- flask 已经安装 --------"
echo "-------- flask is already installed. --------"
fi
exit
EOF
#################### 推送 server 运行的相关文件进入板端 ####################
# 2.检查需要推送进板端的路径是否存在
adb shell ls $2 > /dev/null 2>&1
#################### Push the relevant files for the server to the board. ####################
adb shell ls $WORKING_PATH > /dev/null 2>&1
if [ $? -ne 0 ]; then
# 如果路径不存在,则创建路径
adb shell mkdir -p $2
echo "-------- rkllm_server 工作目录不存在,已创建目录 --------"
adb shell mkdir -p $WORKING_PATH
echo "-------- The rkllm_server working directory does not exist, so it has been created. --------"
else
echo "-------- rkllm_server 工作目录已存在 --------"
echo "-------- The rkllm_server working directory already exists. --------"
fi
# 3.更新 ./rkllm_server/lib 中的 librkllmrt.so 文件
# Update the `librkllmrt.so` file in the `./rkllm_server/lib` directory.
cp ../../runtime/Linux/librkllm_api/aarch64/librkllmrt.so ./rkllm_server/lib/
# 4.推送文件到 Linux 板端
adb push ./rkllm_server $2
adb push ./rkllm_server $WORKING_PATH
#################### Enter the board terminal and start the server service. ####################
CMD="python3 flask_server.py --rkllm_model_path $MODEL_PATH --target_platform $TARGET_PLATFORM --num_npu_core $NPU_CORE_COUNT"
if [[ -n "$LORA_PATH" ]]; then
CMD="$CMD --lora_model_path $LORA_PATH"
fi
if [[ -n "$PROMPT_FILE_PATH" ]]; then
CMD="$CMD --prompt_cache_path $PROMPT_FILE_PATH"
fi
#################### 进入板端并启动 server 服务 ####################
# 5.进入板端启动 server 服务
adb shell << EOF
cd $2/rkllm_server/
python3 flask_server.py --target_platform $1 --rkllm_model_path $3
cd $WORKING_PATH/rkllm_server/
$CMD
EOF