LLM | Xinference 安装使用(支持CPU、Metal、CUDA推理和分布式部署)

news/2024/10/7 19:18:38/

1. 详细步骤

1.1 安装

# 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注:可能是 nvcc 版本等个人环境配置原因,llama-cpp-python 在 CUDA 上无法使用(C/C++ 环境上是正常的),Metal 的 llama-cpp-python 正常。如需安装 flashinfer 等依赖见官方安装文档:https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html

1.2 启动

1.2.1 直接启动

简洁命令
xinference-local --host 0.0.0.0 --port 9997
多参数命令

设置模型缓存路径模型来源(Hugging Face/Modelscope)

# 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

1.2.2 集群部署

通过 ifconfig 查看当前服务器IP

1.2.2.1 主服务器启动 Supervisor
# 格式
xinference-supervisor -H 当前服务器IP(主服务器IP) --port 9997# 示例
xinference-supervisor -H 192.168.31.100 --port 9997
1.2.2.2 其他服务器启动 Worker
# 格式
xinference-worker -e "http://${主服务器IP}:9997" -H 当前服务器IP(子服务器IP)# 示例
xinference-worker -e "http://192.168.31.100:9997" -H 192.168.31.101

注:按需添加XINFERENCE_HOMEXINFERENCE_MODEL_SRCPYTORCH_ENABLE_MPS_FALLBACK等环境变量(启动时参数)

1.3 使用

访问 http://主服务器IP:9997/docs 查看接口文档,访问 http://主服务器IP:9997 正常使用

2. 参考资料

Xinference_71">2.1 Xinference

2.1.1 部署文档
Xinference_75">本地运行 Xinference

https://inference.readthedocs.io/zh-cn/latest/getting_started/using_xinference.html#run-xinference-locally

Xinference_79">集群中部署 Xinference

https://inference.readthedocs.io/zh-cn/latest/getting_started/using_xinference.html#deploy-xinference-in-a-cluster

2.1.2 安装文档
官方页面

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html

Transformers 引擎

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#transformers-backend

LLM__93">vLLM 引擎

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#vllm-backend

Llama.cpp 引擎

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#llama-cpp-backend

MLX 引擎

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#mlx-backend

3. 资源

Xinference_107">3.1 Xinference

3.1.1 GitHub
官方页面

https://github.com/xorbitsai/inference

https://github.com/xorbitsai/inference/blob/main/README_zh_CN.md

3.1.2 安装文档
SGLang 引擎

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#sglang-backend

其他平台(在昇腾 NPU 上安装)

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation.html#other-platforms

https://inference.readthedocs.io/zh-cn/latest/getting_started/installation_npu.html#installation-npu


http://www.ppmy.cn/news/1535830.html

相关文章

57. QT中简单实现发布订阅机制

1. 说明 发布订阅机制可以说是一种消息通信的方式,用于构建分布式系统中不同组件之间的通信,MQTT就是利用这个模式实现的。具体的解释或说明,读者可以搜索一下MQTT的实现原理。本篇博客只是在自己的理解基础上,基于QT写了一个简单的版本:消息的发布和订阅只是简单的使用一…

《数字图像处理基础》学习01-数字图像处理的相关基础知识

这篇文章只是对数字图像处理的相关基础知识有个大概的了解,之后的文章会接着补充和扩展。 目录 一,图像的基本概念 1,图像 2,图像的分类 1)物理图像 2)虚拟图像 二,数字图像处理 三&…

【Mac】和【安卓手机】 通过有线方式实现投屏

Mac 和 安卓手机 实现投屏(有线) 1.下载HomeBrew /bin/bash -c "$(curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install/master/install.sh)"2.安装Scrcpy brew install scrcpy3.安装adb brew install android-platfor…

【分布式微服务云原生】gRPC vs RPC:深入探索远程过程调用的现代与经典

摘要 在分布式系统的世界里,gRPC和RPC是两个耳熟能详的术语,但它们之间有何区别和联系?本文将深入探讨gRPC和RPC的概念、关键特性、以及它们在现代软件开发中的应用。你将了解到gRPC如何作为RPC的一种实现,提供高性能的跨语言远程…

github学生认证(Github Copilot)

今天想配置一下Github Copilot,认证学生可以免费使用一年,认证过程中因为各种原因折腾了好久,记录一下解决方法供大家参考。 p.s.本文章只针对Github学生认证部分遇到的问题及解决方法,不包括配置copilot的全部流程~ 1、准备工作…

万界星空科技MES数据集成平台

制造执行系统MES作为连接企业上层ERP系统和现场控制系统的桥梁,承担了实时数据采集、处理、分析和传递的重要任务。MES数据集成平台是一个集成各类数据源,将数据进行整合和统一管理的系统,通过提供标准化接口和协议,实现数据的无缝…

在线教育系统开发:SpringBoot技术实战

3系统分析 3.1可行性分析 通过对本微服务在线教育系统实行的目的初步调查和分析,提出可行性方案并对其一一进行论证。我们在这里主要从技术可行性、经济可行性、操作可行性等方面进行分析。 3.1.1技术可行性 本微服务在线教育系统采用SSM框架,JAVA作为开…

【JavaEE】——CAS指令和ABA问题

阿华代码,不是逆风,就是我疯 你们的点赞收藏是我前进最大的动力!! 希望本文内容能够帮助到你!! 目录 一:CAS指令 1:概念 2:伪代码例子说明 3:优点 二&am…