为什么要使用xinference
安装xinference
环境
1)conda create -n Xinference python=3.11
注意:3.9 3.10均可能出现xinference 安装时候出现numpy兼容性,以及无法安装all版本
错误: error while attempting to bind on address,no dictory等错误,是由于ssl启动错误引起的。 建议直接安装xinference all版本
注意:单部署
启动:xinference-local --host 127.0.0.1 --port 9997
分类启动
前端:xinference-local --host 127.0.0.1 --port 9997
后端:nohup xinference-local --host 127.0.0.1 --port 9997 & > output.log
涉及版本有
# CUDA/CPU
pip install "xinference[transformers]"
pip install "xinference[vllm]"
pip install "xinference[sglang]"
# Metal(MPS)
pip install "xinference[mlx]"
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
普通启动:xinference-local --host 0.0.0.0 --port 9997
模型启动:
# CUDA/CPU XINFERENCE_HOME=/path/.xinference XINFERENCE_MODEL_SRC=modelscope xinference-local --host 0.0.0.0 --port 9997
# Metal(MPS)
XINFERENCE_HOME=/path/.xinference XINFERENCE_MODEL_SRC=modelscope PYTORCH_ENABLE_MPS_FALLBACK=1 xinference-local --host 0.0.0.0 --port 9997
Xinference支持集群部署
主服务器启动 Supervisor
部署启动: xinference-supervisor -H 192.168.31.100 --port 9997
其他服务器启动 Worker
# 格式 xinference-worker -e "http://${主服务器IP}:9997" -H 当前服务器IP(子服务器IP) # 示例 xinference-worker -e "http://192.168.31.100:9997" -H 192.168.31.101
访问doc地址:http://localhost:9997/docs
(1)注册模型
xinference register --model-type LLM --file custom-glm4-chat.json --persist
(2)启动模型
xinference launch --model-name custom-glm4-chat --model-format pytorch --model-engine Transformers
Langchain-chatchat
错误1
"C:\Users\Administrator\Desktop\Langchain-Chatchat-master\libs\chatchat-server\chatchat\webui_pages\kb_chat.py", line 118, in kb_chat kb_list = [x["kb_name"] for x in api.list_knowledge_bases()
{ "input": "The food was delicious and the waiter...", "model": "360Zhinao-search", "encoding_format": "float" }
注意注意:
请用pip list查看自己httpx版本,我发现最新httpx==0.28.0是不行的,需要0.27.2版本才可以,重新安装后就不会报错了
导致错误是
langchain-chatchat报错Client.__init__() got an unexpected keyword argument ‘proxies‘
错误2
RuntimeError: Cluster is not available after multiple attempts
主要由于启动ip地址host错误,突出表现为0.0.0.0地址,应该本地化使用127.0.0.1