Xinference
Xinference 是专用于大模型的框架,内置了包含 vLLM 在内的多种推理引擎,支持部署包括 LLM,VLM,Embdding,Reranker 多种模型。
- 环境准备:
- 确保您有一台或多台服务器或虚拟机,这些机器将被用作 Xinference 集群的节点。
- 所有的机器都应该安装了相同版本的 Python(Ubuntu23.10自带Python3.11)
- 安装依赖
# 安装 python3 开发套件,虚拟环境
apt-get install python3-dev python3-venv libopenblas-dev
- 安装Xinference框架
# 创建 python3 虚拟环境
python3 -m venv xinference
# 激活虚拟环境
source xinference/bin/activate
# 更新 镜像源
python -m pip install --upgrade pip
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
# 更新 pip3 版本并安装 xinference 框架
pip3 install --upgrade pip
pip3 install "xinference[all]"
启动模型
- 编写脚本
vi xinference_local.sh
mkdir -p /data/www/server/xinference/worker
mkdir -p /data/www/log/xinference
#!/bin/bash
export XINFERENCE_MODEL_SRC=modelscope
export XINFERENCE_HOME=/data/www/server/xinference/worker
nohup xinference-local --host 0.0.0.0 --port 9997 > /data/www/log/xinference/worker.log &
- 执行脚本
chmod +wx xinference_local.sh
./xinference_local.sh
# 启动之后就可以通过本机ip+端口访问ui界面了
# 查看日志
tail -fn 50 /data/www/log/xinference/worker.log
- 通过ui界面部署模型
- 大语言模型:qwen2-7b-instruct 参数: Engine: vLLM; Format: pytorch; Size: 7;Quantization:none;N-GPU:auto;Replicca:1; Additional parameters passed to the inference engine: vLLM gpu_memory_utilization: 0.9;dtype:half
- 向量模型:bge-m3
- 重排模型:bge-reranker-v2-m3
