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

news/2024/10/1 1:26:48

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. 参考资料

2.1 Xinference

2.1.1 部署文档

本地运行 Xinference

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

集群中部署 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

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. 资源

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.ryyt.cn/news/66694.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

KeyShot基础操作1

KeyShot的基本操作,包含视图、导入导出、各个面板简介等内容。注:学习此软件纯粹是工作中突然要我去对接模型厂家,厂家不能对外提供模型原件,于是就自己学了下这个软件渲染模型。--本篇导航--快捷键 视图操作(视图基本操作、几何图形视图) 模型导入、工程保存导出 各个面…

高级语言程序设计第二次个人作业

班级链接:https://edu.cnblogs.com/campus/fzu 作业要求链接:https://edu.cnblogs.com/campus/fzu/2024C/homework/13282 学号:102400130 姓名:杨子旭 章节习题在第四题的时候发现即使代码正确也无法输出正确结果,最后发现是win7系统原因,测试发现在win10的系统可以转为十…

YouTube 注释 All In One

YouTube 注释 All In OneYouTube 注释 All In One old YouTube 批注是在视频上添加文字层,链接或热点。 他们添加了链接到其他网站或视频的交互式框(您想要的任何链接)。https://zh-cn.aiseesoft.com/how-to/add-annotations-to-youtube.html将注释支持带回 YouTube™! 201…

AnimationClip优化工具 - 删除连续相同的帧

下图中Rotation.z的前4个关键帧[0, 3](即15帧, 30帧, 45帧, 60帧),值都没变; (3, 4)Rotation.z变为60(即61帧到90帧); 后3个关键帧[5, 7]一直维持在60没变。可以分析下:前4个关键帧,[1, 2]删除对动画没影响,后3个关键帧[5, 7]删除对动画也没影响。public class AnimC…

实验1 C语言输入输出和简单程序编写

一,实验目的 1. 会使用C语言程序开发环境(vs2010/devc++等),能熟练、正确使用它们编写、编译、运行、调 试C程序 2. 知道C程序结构和编码规范,能正确使用 3. 能正确、熟练使用C语言输入输出函数: scanf() , printf() , getchar() , putchar() 4. 能灵活、组合使用基本数据…

VScode Cmake-tools 部分问题记录

我的 Visual Studio Code 先前一直安装了 cpp-tools 和 cmake-tools。随后,我升级了我的 GCC 环境版本。然而,重新启动 Visual Studio Code 后,旧的 GCC 版本仍保留在工具包中。起初,我以为是 cpp-tools 插件的问题,一直无法解决这个 bug。后来卸载了相关插件后才发现是 c…

数组0.1

一维数组 数组的运用场合 当我们需要涉及的变量特别多,光想名字都要想半天 所以引入数组 Q: (1)在程序中怎样存放100个学生的成绩? (2)定义100个整型变量吗? (3)C语言中的解决方案是……? A: (1)存储学生成绩用整型数组 mark[100]; (2)存储一行文字用字符数组 …

opencascade AIS_WalkDelta、AIS_ViewInputBuffer源码学习工作

opencascade AIS_WalkDelta 前言 运行方法 1. 空构造函数。 AIS_WalkDelta() : myIsDefined(false), myIsJumping(false), myIsCrouching(false), myIsRunning(false) {} 2. 返回平移组件。 const AIS_WalkPart& operator[] (AIS_WalkTranslation thePart) ; 3. 返回平移组…