mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-08 20:39:44 +00:00
feat: Support 8-bit quantization and 4-bit quantization for multi-gpu inference
This commit is contained in:
@@ -1,25 +1,48 @@
|
||||
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
|
||||
ARG BASE_IMAGE="nvidia/cuda:11.8.0-devel-ubuntu22.04"
|
||||
|
||||
FROM ${BASE_IMAGE}
|
||||
ARG BASE_IMAGE
|
||||
|
||||
RUN apt-get update && apt-get install -y git python3 pip wget \
|
||||
&& apt-get clean
|
||||
|
||||
# download code from githu: https://github.com/csunny/DB-GPT
|
||||
# ENV DBGPT_VERSION="v0.3.3"
|
||||
# RUN wget https://github.com/csunny/DB-GPT/archive/refs/tags/$DBGPT_VERSION.zip
|
||||
ARG BUILD_LOCAL_CODE="false"
|
||||
ARG LANGUAGE="en"
|
||||
ARG PIP_INDEX_URL="https://pypi.org/simple"
|
||||
ENV PIP_INDEX_URL=$PIP_INDEX_URL
|
||||
|
||||
# clone latest code, and rename to /app
|
||||
RUN git clone https://github.com/csunny/DB-GPT.git /app
|
||||
# COPY only requirements.txt first to leverage Docker cache
|
||||
COPY ./requirements.txt /tmp/requirements.txt
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip3 install --upgrade pip \
|
||||
&& pip3 install --no-cache-dir -r requirements.txt \
|
||||
&& pip3 install seaborn mpld3 \
|
||||
&& wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& rm -rf `pip3 cache dir`
|
||||
RUN pip3 install --upgrade pip -i $PIP_INDEX_URL \
|
||||
&& (if [ "${BUILD_LOCAL_CODE}" = "false" ]; \
|
||||
# if not build local code, clone latest code from git, and rename to /app, TODO: download by version, like: https://github.com/eosphoros-ai/DB-GPT/archive/refs/tags/$DBGPT_VERSION.zip
|
||||
then git clone https://github.com/eosphoros-ai/DB-GPT.git /app \
|
||||
&& cp /app/requirements.txt /tmp/requirements.txt; \
|
||||
fi;) \
|
||||
&& pip3 install -r /tmp/requirements.txt -i $PIP_INDEX_URL --no-cache-dir \
|
||||
&& rm /tmp/requirements.txt
|
||||
|
||||
# RUN python3 -m spacy download zh_core_web_sm
|
||||
RUN (if [ "${LANGUAGE}" = "zh" ]; \
|
||||
# language is zh, download zh_core_web_sm from github
|
||||
then wget https://github.com/explosion/spacy-models/releases/download/zh_core_web_sm-3.5.0/zh_core_web_sm-3.5.0-py3-none-any.whl -O /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl \
|
||||
&& pip3 install /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl -i $PIP_INDEX_URL \
|
||||
&& rm /tmp/zh_core_web_sm-3.5.0-py3-none-any.whl; \
|
||||
# not zh, download directly
|
||||
else python3 -m spacy download zh_core_web_sm; \
|
||||
fi;) \
|
||||
&& rm -rf `pip3 cache dir`
|
||||
|
||||
ARG BUILD_LOCAL_CODE="false"
|
||||
# COPY the rest of the app
|
||||
COPY . /tmp/app
|
||||
|
||||
# TODO:Need to find a better way to determine whether to build docker image with local code.
|
||||
RUN (if [ "${BUILD_LOCAL_CODE}" = "true" ]; \
|
||||
then mv /tmp/app / && rm -rf /app/logs && rm -rf /app/pilot/data && rm -rf /app/pilot/message; \
|
||||
else rm -rf /tmp/app; \
|
||||
fi;)
|
||||
|
||||
EXPOSE 5000
|
@@ -4,5 +4,72 @@ SCRIPT_LOCATION=$0
|
||||
cd "$(dirname "$SCRIPT_LOCATION")"
|
||||
WORK_DIR=$(pwd)
|
||||
|
||||
BASE_IMAGE="nvidia/cuda:11.8.0-devel-ubuntu22.04"
|
||||
IMAGE_NAME="db-gpt"
|
||||
docker build -f Dockerfile -t $IMAGE_NAME $WORK_DIR/../../
|
||||
# zh: https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
PIP_INDEX_URL="https://pypi.org/simple"
|
||||
# en or zh
|
||||
LANGUAGE="en"
|
||||
BUILD_LOCAL_CODE="false"
|
||||
|
||||
usage () {
|
||||
echo "USAGE: $0 [--base-image nvidia/cuda:11.8.0-devel-ubuntu22.04] [--image-name db-gpt]"
|
||||
echo " [-b|--base-image base image name] Base image name"
|
||||
echo " [-n|--image-name image name] Current image name, default: db-gpt"
|
||||
echo " [-i|--pip-index-url pip index url] Pip index url, default: https://pypi.org/simple"
|
||||
echo " [--language en or zh] You language, default: en"
|
||||
echo " [--build-local-code true or false] Whether to use the local project code to package the image, default: false"
|
||||
echo " [-h|--help] Usage message"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-b|--base-image)
|
||||
BASE_IMAGE="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-n|--image-name)
|
||||
IMAGE_NAME="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-i|--pip-index-url)
|
||||
PIP_INDEX="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--language)
|
||||
LANGUAGE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--build-local-code)
|
||||
BUILD_LOCAL_CODE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
help="true"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $help ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
docker build \
|
||||
--build-arg BASE_IMAGE=$BASE_IMAGE \
|
||||
--build-arg PIP_INDEX_URL=$PIP_INDEX_URL \
|
||||
--build-arg LANGUAGE=$LANGUAGE \
|
||||
--build-arg BUILD_LOCAL_CODE=$BUILD_LOCAL_CODE \
|
||||
-f Dockerfile \
|
||||
-t $IMAGE_NAME $WORK_DIR/../../
|
||||
|
@@ -4,6 +4,11 @@ SCRIPT_LOCATION=$0
|
||||
cd "$(dirname "$SCRIPT_LOCATION")"
|
||||
WORK_DIR=$(pwd)
|
||||
|
||||
bash $WORK_DIR/base/build_image.sh
|
||||
bash $WORK_DIR/base/build_image.sh "$@"
|
||||
|
||||
if [ 0 -ne $? ]; then
|
||||
ehco "Error: build base image failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bash $WORK_DIR/allinone/build_image.sh
|
Reference in New Issue
Block a user