news 2026/6/10 13:53:32

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
LLM Xinference 安装使用(支持CPU、Metal、CUDA推理和分布式部署)

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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/10 9:54:55

Mysql ONLY_FULL_GROUP_BY模式详解、group by非查询字段报错

文章目录 一、问题报错二、ONLY_FULL_GROUP_BY模式 2.1、什么是ONLY_FULL_GROUP_BY?2.2、为什么要使用ONLY_FULL_GROUP_BY?2.3、查看sql_mode 三、解决方法 3.1、关闭only_full_group_by模式 3.1.1、方法一:关闭当前会话中的only_full_group…

作者头像 李华
网站建设 2026/6/10 9:56:13

MS SQL Server partition by 函数实战三 成绩排名

目录 需求 范例运行环境 视图样本设计 功能实现 基础数据展示 SQL语句 继续排序 小结 需求 假设有若干已更新考试成绩的考生,考试成绩包括总成绩、分项成绩1、分项成绩2,其它信息包括应聘岗位名称、姓名等信息。现希望根据总成绩计算排名&#…

作者头像 李华
网站建设 2026/6/10 9:57:38

从普通产品经理到AI产品经理,你需要掌握的AI思维与核心技能:AI大模型产品经理从零基础到进阶

AI产品经理与普通产品经理的核心区别在于AI思维。人工智能产业链分为基础层、技术层和应用层。AI产品经理可分为突破型、创新型、应用型和普及型四类,需找准定位,避免常见误区。提升能力需专注目标领域,持续学习,扩大交流圈&#…

作者头像 李华
网站建设 2026/6/10 9:55:00

Thinkphp和Laravel框架的成都某民宿预订系统的设计与实现_r93v34dv

目录摘要项目开发技术介绍PHP核心代码部分展示系统结论源码获取/同行可拿货,招校园代理摘要 本研究基于ThinkPHP和Laravel框架,设计并实现了一款面向成都地区的民宿预订系统。系统采用B/S架构,结合MySQL数据库,旨在为用户提供高效的房源查询…

作者头像 李华
网站建设 2026/6/10 9:51:11

由continue引发的一个debug灾难

整个代码的简化逻辑是这样的,由于continue的使用含义不清楚,导致debug了半天。这里写代码时,错误的将continue认为是else分支,什么也不干,往下继续执行。 但是这样的理解是极其错误的,continue的意思是跳过…

作者头像 李华
网站建设 2026/6/10 9:53:56

knife4j+springboot3.4异常无法正确展示文档

场景复现: knife4j-openapi3-jakarta-spring-boot-starter版本 com.github.xiaoymin knife4j-openapi3-jakarta-spring-boot-starter 4.5.0 原来使用springboot3.3.5版本,先升级到3.4.0版本 通过http://ip:port/doc.html访问接口文档发现访问/v3/api-d…

作者头像 李华