项目地址:https://github.com/netease-youdao/QAnything
1, docker-compose-linux.ymal
version: '3.5'services:elasticsearch:container_name: es-container-localimage: "docker.elastic.co/elasticsearch/elasticsearch:8.11.4"privileged: true# ports:# - 9200:9200# - 9300:9300restart: on-failureenvironment:- discovery.type=single-node- xpack.security.enabled=false- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/third_party/es/plugins:/usr/share/elasticsearch/plugins- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/es/data:/usr/share/elasticsearch/datahealthcheck:test: curl --fail http://localhost:9200/_cat/health || exit 1interval: 30stimeout: 20sretries: 3etcd:container_name: milvus-etcd-localimage: quay.io/coreos/etcd:v3.5.5environment:- ETCD_AUTO_COMPACTION_MODE=revision- ETCD_AUTO_COMPACTION_RETENTION=1000- ETCD_QUOTA_BACKEND_BYTES=4294967296- ETCD_SNAPSHOT_COUNT=50000volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcdcommand: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcdhealthcheck:test: ["CMD", "etcdctl", "endpoint", "health"]interval: 30stimeout: 20sretries: 3minio:container_name: milvus-minio-localimage: minio/minio:RELEASE.2023-03-20T20-16-18Zenvironment:MINIO_ACCESS_KEY: minioadminMINIO_SECRET_KEY: minioadmin# ports:# - "9001:9001"# - "9000:9000"volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_datacommand: minio server /minio_data --console-address ":9001"healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3standalone:container_name: milvus-standalone-localimage: milvusdb/milvus:v2.3.4logging:driver: "json-file"options:max-size: "100m"max-file: "3"command: ["milvus", "run", "standalone"]security_opt:- seccomp:unconfinedenvironment:ETCD_ENDPOINTS: etcd:2379MINIO_ADDRESS: minio:9000volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvushealthcheck:test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]interval: 30sstart_period: 90stimeout: 20sretries: 3# ports:# - "19530:19530"# - "9091:9091"depends_on:- "etcd"- "minio"mysql:container_name: mysql-container-localprivileged: trueimage: mysql# ports:# - "3306:3306"command: --max-connections=10000environment:- MYSQL_ROOT_PASSWORD=123456volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/mysql:/var/lib/mysqlqanything_local:container_name: qanything-container-localimage: freeren/qanything:v1.2.2# runtime: nvidiadeploy:resources:reservations:devices:- driver: nvidiacount: "all"capabilities: ["gpu"]command: /bin/bash -c 'if [ "${LLM_API}" = "local" ]; then /workspace/qanything_local/scripts/run_for_local_option.sh -c $LLM_API -i $DEVICE_ID -b $RUNTIME_BACKEND -m $MODEL_NAME -t $CONV_TEMPLATE -p $TP -r $GPU_MEM_UTILI; else /workspace/qanything_local/scripts/run_for_cloud_option.sh -c $LLM_API -i $DEVICE_ID -b $RUNTIME_BACKEND; fi; while true; do sleep 5; done'privileged: trueshm_size: '8gb'volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/assets/custom_models:/model_repos/CustomLLM- ${DOCKER_VOLUME_DIRECTORY:-.}/:/workspace/qanything_local/ports:- "8777:8777"environment:- NCCL_LAUNCH_MODE=PARALLEL- GPUID1=${GPUID1:-0}- GPUID2=${GPUID2:-0}- MODEL_SIZE=${MODEL_SIZE:-0B}- USER_IP=${USER_IP:-localhost}depends_on:- "standalone"- "mysql"- "elasticsearch"tty: truestdin_open: truenetworks:default:name: qanything_milvus_mysql_local
其中的gpu写法
# runtime: nvidiadeploy:resources:reservations:devices:- driver: nvidiacount: "all"capabilities: ["gpu"]
1, docker-compose-windows.ymal
version: '3.5'services:elasticsearch:container_name: es-container-localimage: "docker.elastic.co/elasticsearch/elasticsearch:8.11.4"privileged: true# ports:# - 9200:9200# - 9300:9300restart: on-failureenvironment:- discovery.type=single-node- xpack.security.enabled=false- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/third_party/es/plugins:/usr/share/elasticsearch/plugins- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/es/data:/usr/share/elasticsearch/datahealthcheck:test: curl --fail http://localhost:9200/_cat/health || exit 1interval: 30stimeout: 20sretries: 3etcd:container_name: milvus-etcd-localimage: quay.io/coreos/etcd:v3.5.5environment:- ETCD_AUTO_COMPACTION_MODE=revision- ETCD_AUTO_COMPACTION_RETENTION=1000- ETCD_QUOTA_BACKEND_BYTES=4294967296- ETCD_SNAPSHOT_COUNT=50000volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcdcommand: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcdhealthcheck:test: ["CMD", "etcdctl", "endpoint", "health"]interval: 30stimeout: 20sretries: 3minio:container_name: milvus-minio-localimage: minio/minio:RELEASE.2023-03-20T20-16-18Zenvironment:MINIO_ACCESS_KEY: minioadminMINIO_SECRET_KEY: minioadmin# ports:# - "9001:9001"# - "9000:9000"volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_datacommand: minio server /minio_data --console-address ":9001"healthcheck:test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]interval: 30stimeout: 20sretries: 3standalone:container_name: milvus-standalone-localimage: milvusdb/milvus:v2.3.4logging:driver: "json-file"options:max-size: "100m"max-file: "3"command: ["milvus", "run", "standalone"]security_opt:- seccomp:unconfinedenvironment:ETCD_ENDPOINTS: etcd:2379MINIO_ADDRESS: minio:9000volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvushealthcheck:test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]interval: 30sstart_period: 90stimeout: 20sretries: 3# ports:# - "19530:19530"# - "9091:9091"depends_on:- "etcd"- "minio"mysql:container_name: mysql-container-localprivileged: trueimage: mysql# ports:# - "3306:3306"command: --max-connections=10000environment:- MYSQL_ROOT_PASSWORD=123456volumes:- qanything_mysql_data:/var/lib/mysqlqanything_local:container_name: qanything-container-localimage: freeren/qanything-win:v1.2.2# runtime: nvidiadeploy:resources:reservations:devices:- driver: nvidiacount: "all"capabilities: ["gpu"]command: sh -c 'if [ "${LLM_API}" = "local" ]; then /workspace/qanything_local/scripts/run_for_local_option.sh -c $LLM_API -i $DEVICE_ID -b $RUNTIME_BACKEND -m $MODEL_NAME -t $CONV_TEMPLATE -p $TP -r $GPU_MEM_UTILI; else /workspace/qanything_local/scripts/run_for_cloud_option.sh -c $LLM_API -i $DEVICE_ID -b $RUNTIME_BACKEND; fi; while true; do sleep 5; done'privileged: trueshm_size: '8gb'volumes:- ${DOCKER_VOLUME_DIRECTORY:-.}/assets/custom_models:/model_repos/CustomLLM- ${DOCKER_VOLUME_DIRECTORY:-.}/:/workspace/qanything_local/ports:- "8777:8777"environment:- NCCL_LAUNCH_MODE=PARALLEL- GPUID1=${GPUID1:-0}- GPUID2=${GPUID2:-0}- MODEL_SIZE=${MODEL_SIZE:-0B}- USER_IP=${USER_IP:-localhost}depends_on:- "standalone"- "mysql"- "elasticsearch"tty: truestdin_open: truevolumes:qanything_mysql_data:networks:default:name: qanything_milvus_mysql_local
设置好networks, 容器内的服务就可以互相访问了
3, Dockerfile
ARG TRITON_VERSION=23.05
ARG BASE_IMAGE=nvcr.io/nvidia/tritonserver:${TRITON_VERSION}-py3
ARG PIP_OPTIONS="-i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn"
FROM ${BASE_IMAGE}# 设置非交互式前端,防止在安装过程中出现交云提示
ENV DEBIAN_FRONTEND=noninteractiveRUN apt-get update && apt install -y tzdata && \ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \echo "Asia/Shanghai" > /etc/timezone && \dpkg-reconfigure --frontend noninteractive tzdataRUN apt-get install -y --no-install-recommends \autoconf \autogen \clangd \git-lfs \libb64-dev \libz-dev \locales-all \mosh \openssh-server \python3-dev \rapidjson-dev \sudo \unzip \zstd \lsof \netcat \net-tools \zip \libgl1-mesa-glx \libmagic-dev \poppler-utils \tesseract-ocr \libxml2-dev \libxslt1-dev \zsh && \apt-get clean && \rm -rf /usr/local/cuda-11.8 && \rm -rf /var/lib/apt/lists/*RUN python3 -m pip install $PIP_OPTIONS --upgrade pip && pip install $PIP_OPTIONS --no-cache-dir --extra-index-url https://pypi.ngc.nvidia.com regex==2023.10.3 fire==0.5.0 && \pip install $PIP_OPTIONS --no-cache-dir --ignore-installed blinker==1.7.0 && \pip install $PIP_OPTIONS --no-cache-dir tqdm==4.66.1 omegaconf==2.3.0 concurrent-log-handler==0.9.25 && \pip install $PIP_OPTIONS --no-cache-dir numpy==1.23.4 transformers==4.31.0 tiktoken==0.4.0 kazoo==2.9.0 psutil==5.9.0 sentencepiece==0.1.99 tritonclient[all]==2.31.0 pynvml==11.5.0 gunicorn==21.2.0 uvicorn==0.25.0 && \pip install $PIP_OPTIONS --no-cache-dir ipython==8.17.2 sanic==23.6.0 pymilvus==2.3.4 langchain==0.0.351 paddleocr==2.7.0.3 paddlepaddle-gpu==2.5.2 nltk==3.8.1 pypinyin==0.50.0 mysql-connector-python==8.2.0 sanic_ext==23.6.0 && \pip install $PIP_OPTIONS --no-cache-dir onnxruntime-gpu==1.16.3 openai==1.6.1 && \pip install $PIP_OPTIONS --no-cache-dir unstructured==0.11.6 unstructured[pptx]==0.11.6 unstructured[md]==0.11.6# Add FT-backend
RUN rm -rf /opt/tritonserver/include && rm -rf /opt/tritonserver/third-party-src && mv /opt/tritonserver/backends/onnxruntime /opt/tritonserver/onnxruntime && rm -rf /opt/tritonserver/backends && mkdir -p /opt/tritonserver/backends && mkdir /model_repos && mv /opt/tritonserver/onnxruntime /opt/tritonserver/backends/onnxruntime
ENV WORKSPACE /workspace
WORKDIR /workspace
COPY nltk_data /root/nltk_data
COPY paddleocr /root/.paddleocr
COPY qa_ensemble /opt/tritonserver/backends/qa_ensemble
# EXPOSE 8288# 下载Node.js指定版本的压缩包
RUN wget https://nodejs.org/download/release/v18.19.0/node-v18.19.0-linux-x64.tar.gz# 创建目录用于存放Node.js
RUN mkdir -p /usr/local/lib/nodejs# 解压Node.js压缩包到指定目录
RUN tar -zxvf node-v18.19.0-linux-x64.tar.gz -C /usr/local/lib/nodejs# 设置环境变量,将Node.js的bin目录加入到PATH中
ENV PATH="/usr/local/lib/nodejs/node-v18.19.0-linux-x64/bin:${PATH}"RUN rm /workspace/node-v18.19.0-linux-x64.tar.gzRUN mkdir /opt/tiktoken_cache
ARG TIKTOKEN_URL="https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken"
RUN wget -O /opt/tiktoken_cache/$(echo -n $TIKTOKEN_URL | sha1sum | head -c 40) $TIKTOKEN_URL
ENV TIKTOKEN_CACHE_DIR=/opt/tiktoken_cache
# 启动nginx
# CMD ["nginx", "-g", "daemon off;"]RUN sed -i 's/#X11UseLocalhost yes/X11UseLocalhost no/g' /etc/ssh/sshd_config && \mkdir /var/run/sshd -p