windows 10下安装xinference,以及RuntimeError: Cluster is not available after multiple attempts错误解决

系统以及软件版本

  • xinference 1.1.0
  • Anaconda 3
  • windows 10
  • python 3.10.15

windows 10 下安装xinference

Xinference 在 Linux, Windows, MacOS 上都可以通过 pip 来安装。如果需要使用 Xinference 进行模型推理,可以根据不同的模型指定不同的引擎。

如果你希望能够推理所有支持的模型,可以用以下命令安装所有需要的依赖:

pip install xinference[all]

xinference支持的推理引擎包括:Transformers 引擎、vLLM 引擎、Llama.cpp 引擎、SGLang 引擎、MLX 引擎等。

Transformers 引擎

PyTorch(transformers) 引擎支持几乎有所的最新模型,这是 Pytorch 模型默认使用的引擎

vLLM 引擎

vLLM 是一个支持高并发的高性能大模型推理引擎。当满足以下条件时,Xinference 会自动选择 vllm 作为引擎来达到更高的吞吐量

Llama.cpp 引擎

Xinference 通过 llama-cpp-python 支持 gguf 格式的模型。建议根据当前使用的硬件手动安装依赖,从而获得最佳的加速效果。

SGLang 引擎

SGLang 具有基于 RadixAttention 的高性能推理运行时。它通过在多个调用之间自动重用KV缓存,显著加速了复杂 LLM 程序的执行。它还支持其他常见推理技术,如连续批处理和张量并行处理。

MLX 引擎

MLX-lm 用来在苹果 silicon 芯片上提供高效的 LLM 推理。

基于Transformers 引擎的xinference安装

第一步:创建虚拟环境

conda create -n xinference python=3.10.15

第二步:进入创建的虚拟环境

conda activate xinfernece

第二步:安装xinference

pip install "xinference[transformers]"

第三步:验证安装

安装完成之后,在CMD命令行中输入如下命令:

python -c "import xinference; print(xinference.__version__)"

如果正常导入,说明安装成功。

RuntimeError: Cluster is not available after multiple attempts错误解决

安装成功后就可以启动了,官方给出的启动代码如下:

xinference-local --host 0.0.0.0 --port 9997

但是在windows中如果使用以上代码启动会报错,报错信息如下:

(xinference) D:\models>xinference-local --host 0.0.0.0 --port 9997
2024-12-20 15:15:55,754 xinference.core.supervisor 23104 INFO     Xinference supervisor 0.0.0.0:54541 started
2024-12-20 15:15:55,765 xinference.core.worker 23104 INFO     Starting metrics export server at 0.0.0.0:None
2024-12-20 15:15:55,768 xinference.core.worker 23104 INFO     Checking metrics export server...
2024-12-20 15:16:05,154 xinference.core.worker 23104 INFO     Metrics server is started at: http://0.0.0.0:58268
2024-12-20 15:16:05,155 xinference.core.worker 23104 INFO     Purge cache directory: C:\Users\Administrator\.xinference\cache
2024-12-20 15:16:05,157 xinference.core.worker 23104 INFO     Connected to supervisor as a fresh worker
2024-12-20 15:16:05,166 xinference.core.worker 23104 INFO     Xinference worker 0.0.0.0:54541 started
Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\ProgramData\Anaconda3\envs\xinference\Scripts\xinference-local.exe\__main__.py", line 7, in <module>
    sys.exit(local())
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\xinference\deploy\cmdline.py", line 226, in local
    start_local_cluster(
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\xinference\deploy\cmdline.py", line 113, in start_local_cluster
    main(
  File "D:\ProgramData\Anaconda3\envs\xinference\lib\site-packages\xinference\deploy\local.py", line 122, in main
    raise RuntimeError("Cluster is not available after multiple attempts")
RuntimeError: Cluster is not available after multiple attempts

出现这个报错的原因是启动命令使用的时linux的启动方式,Windows 上不支持用 0.0.0.0 启动,应使用 IP。

修改启动命令如下即可:

xinference-local --host 127.0.0.1 --port 9997
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

脑洞笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值