Qanything-docker-compose yaml文件(内含GPU 配置,备用学习)

项目地址:https://github.com/netease-youdao/QAnything

1, docker-compose-linux.ymal

yaml 复制代码
version: '3.5'

services:
  elasticsearch:
    container_name: es-container-local
    image: "docker.elastic.co/elasticsearch/elasticsearch:8.11.4"
    privileged: true
    # ports:
    #   - 9200:9200
    #   - 9300:9300
    restart: on-failure
    environment:
      - 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/data
    healthcheck:
      test: curl --fail http://localhost:9200/_cat/health || exit 1
      interval: 30s
      timeout: 20s
      retries: 3

  etcd:
    container_name: milvus-etcd-local
    image: quay.io/coreos/etcd:v3.5.5
    environment:
      - ETCD_AUTO_COMPACTION_MODE=revision
      - ETCD_AUTO_COMPACTION_RETENTION=1000
      - ETCD_QUOTA_BACKEND_BYTES=4294967296
      - ETCD_SNAPSHOT_COUNT=50000
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
    command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
    healthcheck:
      test: ["CMD", "etcdctl", "endpoint", "health"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio:
    container_name: milvus-minio-local
    image: minio/minio:RELEASE.2023-03-20T20-16-18Z
    environment:
      MINIO_ACCESS_KEY: minioadmin
      MINIO_SECRET_KEY: minioadmin
    # ports:
    #   - "9001:9001"
    #       - "9000:9000"
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
    command: minio server /minio_data --console-address ":9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  standalone:
    container_name: milvus-standalone-local
    image: milvusdb/milvus:v2.3.4
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"
    command: ["milvus", "run", "standalone"]
    security_opt:
    - seccomp:unconfined
    environment:
      ETCD_ENDPOINTS: etcd:2379
      MINIO_ADDRESS: minio:9000
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
      interval: 30s
      start_period: 90s
      timeout: 20s
      retries: 3
    # ports:
    #       - "19530:19530"
    #       - "9091:9091"
    depends_on:
      - "etcd"
      - "minio"

  mysql:
    container_name: mysql-container-local
    privileged: true
    image: mysql
    #     ports:
    #       - "3306:3306"
    command: --max-connections=10000
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/mysql:/var/lib/mysql


  qanything_local:
    container_name: qanything-container-local
    image: freeren/qanything:v1.2.2
    # runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: "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: true
    shm_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: true
    stdin_open: true

networks:
  default:
    name: qanything_milvus_mysql_local

其中的gpu写法

yaml 复制代码
# runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: "all"
              capabilities: ["gpu"]

1, docker-compose-windows.ymal

yaml 复制代码
version: '3.5'

services:
  elasticsearch:
    container_name: es-container-local
    image: "docker.elastic.co/elasticsearch/elasticsearch:8.11.4"
    privileged: true
    # ports:
    #   - 9200:9200
    #   - 9300:9300
    restart: on-failure
    environment:
      - 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/data
    healthcheck:
      test: curl --fail http://localhost:9200/_cat/health || exit 1
      interval: 30s
      timeout: 20s
      retries: 3

  etcd:
    container_name: milvus-etcd-local
    image: quay.io/coreos/etcd:v3.5.5
    environment:
      - ETCD_AUTO_COMPACTION_MODE=revision
      - ETCD_AUTO_COMPACTION_RETENTION=1000
      - ETCD_QUOTA_BACKEND_BYTES=4294967296
      - ETCD_SNAPSHOT_COUNT=50000
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
    command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
    healthcheck:
      test: ["CMD", "etcdctl", "endpoint", "health"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio:
    container_name: milvus-minio-local
    image: minio/minio:RELEASE.2023-03-20T20-16-18Z
    environment:
      MINIO_ACCESS_KEY: minioadmin
      MINIO_SECRET_KEY: minioadmin
    # ports:
    #   - "9001:9001"
    #       - "9000:9000"
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
    command: minio server /minio_data --console-address ":9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  standalone:
    container_name: milvus-standalone-local
    image: milvusdb/milvus:v2.3.4
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"
    command: ["milvus", "run", "standalone"]
    security_opt:
    - seccomp:unconfined
    environment:
      ETCD_ENDPOINTS: etcd:2379
      MINIO_ADDRESS: minio:9000
    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
      interval: 30s
      start_period: 90s
      timeout: 20s
      retries: 3
    # ports:
    #       - "19530:19530"
    #       - "9091:9091"
    depends_on:
      - "etcd"
      - "minio"

  mysql:
    container_name: mysql-container-local
    privileged: true
    image: mysql
    #     ports:
    #       - "3306:3306"
    command: --max-connections=10000
    environment:
      - MYSQL_ROOT_PASSWORD=123456
    volumes:
      - qanything_mysql_data:/var/lib/mysql

  qanything_local:
    container_name: qanything-container-local
    image: freeren/qanything-win:v1.2.2
    # runtime: nvidia
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: "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: true
    shm_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: true
    stdin_open: true

volumes:
  qanything_mysql_data:

networks:
  default:
    name: qanything_milvus_mysql_local

设置好networks, 容器内的服务就可以互相访问了

3, Dockerfile

yaml 复制代码
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=noninteractive

RUN 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 tzdata

RUN 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.gz

RUN 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
相关推荐
lwprain11 分钟前
常用docker应用部署,wordpress、mysql、tomcat、nginx、redis
mysql·docker·tomcat
Code_Artist2 小时前
使用Portainer来管理并编排Docker容器
docker·云原生·容器
mengao12342 小时前
centos 服务器 docker 使用代理
服务器·docker·centos
Eternal-Student2 小时前
【docker 保存】将Docker镜像保存为一个离线的tar归档文件
运维·docker·容器
不是二师兄的八戒2 小时前
本地 PHP 和 Java 开发环境 Docker 化与配置开机自启
java·docker·php
码农小丘2 小时前
一篇保姆式centos/ubuntu安装docker
运维·docker·容器
Eternal-Student3 小时前
【1.2 Getting Started--->Installation Guide】
docker
yunfanleo5 小时前
docker run m3e 配置网络,自动重启,GPU等 配置渠道要点
linux·运维·docker
梅见十柒6 小时前
wsl2中kali linux下的docker使用教程(教程总结)
linux·经验分享·docker·云原生
意疏20 小时前
【Linux 篇】Docker 的容器之海与镜像之岛:于 Linux 系统内探索容器化的奇妙航行
linux·docker