xinference Error code: 400 - {‘detail‘: ‘[address=0.0.0.0:23015, pid=8661] Model not found,uid

该文章已生成可运行项目,

今天使用xinferece 时遇到1个错误,开启的是qwen2-vl-instruct ,7B 模型,GPTQ int4 量化版本,xinference 0.16.1,ubuntu 22.04 系统

送入的message 如下

completion = client_local.chat.completions.create(
    model="qwen2-vl-instruct",   
    messages=[
            {
            "role": "user",
            "content": [
                {
                "type": "image_url",
                "image_url": {"url": f"data:image/jpeg;base64,{step_0}"},
                },
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/jpeg;base64,{step_1}"},
                },
            {
                "type": "image_url",
                "image_url": {"url": f"data:image/jpeg;base64,{step_2}"},
            },
            {"type": "text","text": "这三个步骤有什么区别与联系"},
            ]
            }
    ]
)

从messages 可以看出,有3个图片,一个文本

openai.BadRequestError: Error code: 400 - {'detail': '[address=0.0.0.0:23015, pid=8661] Model not found, uid: qwen2-vl-instruct-1-0'}
我传递的model参数是qwen2-vl-instruct,已确认model="qwen2-vl-instruct",

同时,在xinference启动的模型里,Model uid 没有进行特别设置,采取的默认,即model uid =model name

刚开始,一直以为是传递参数错了,反复检查传递参数,并进行打印,直到底层openai/_base_client.py,在函数def _request,有一行语句:options = self._prepare_options(options),得到参数options,获得模型的方式是option.dict()["json_data"]["model"],再向后就是httpx 直接post 调用,目前是打印参数的最佳时机,我每次调用都把它打印出来,结果确认,这个模型参数一直是qwen2-vl-instruct,没有变化

这么说来,每次调用,传递的模型参数是没有错误的,但是问题出现在哪里呢

因为后面还有几行

            response = self._client.send(
                request,
                stream=stream or self._should_stream_response_body(request=request),
                **kwargs,
            )

这个是httpx 直接调用接口的语句,想到把每次的结果都打印一下,可以看到如下:

in openai/_base_client.py,model:qwen2-vl-instruct
in openai/_base_client.py,response:<Response [500 Internal Server Error]>,response.content:b'{"detail":"[address=0.0.0.0:35301, pid=515686] You set image=2 (or defaulted to 1) in `--limit-mm-per-prompt`, but found 3 items in the same prompt."}'
in openai/_base_client.py,model:qwen2-vl-instruct
in openai/_base_client.py,response:<Response [500 Internal Server Error]>,response.content:b'{"detail":"Remote server 0.0.0.0:35301 closed"}'
in openai/_base_client.py,model:qwen2-vl-instruct
in openai/_base_client.py,response:<Response [400 Bad Request]>,response.content:b'{"detail":"[address=0.0.0.0:23015, pid=8661] Model not found, uid: qwen2-vl-instruct-1-0"}'
可以看到错误不是一次产生的,首先第一次请求时错误,发现了3张图片,它可以处理2张图片,但不能同时处理3张图片,这个xinference model worker (侦听端口35301)无法处理,需要设置参数,

第二次请求时代表这个model worker (侦听端口35301),由于遇到上述错误,已经关闭了

第三次请求报的错误也就是最终遇到的错误,Model not found,

但问题来了,问什么第三次请求报的错误才是最终的错误,

这里有1个重试机制,就是在出错时,进行重试,代码里的语句是

 remaining_retries = options.get_max_retries(self.max_retries) - retries_taken

把剩下的次数也打印出来,再执行一次

执行前保留一下数据,nvidia-smi查看目前model worker 占用进程号

    0   N/A  N/A    516171      C   ...naconda3/envs/xinference/bin/python    16008MiB

516171的是xinference model worker 的进程号,查询一下它目前在那些端口上进行侦听

tcp        0      0 0.0.0.0:39257           0.0.0.0:*               LISTEN      516171/python       
tcp        0      0 10.18.120.185:46623     0.0.0.0:*               LISTEN      516171/python       
tcp        0      0 10.18.120.185:43229     0.0.0.0:*               LISTEN      516171/python       
tcp        0      0 10.18.120.185:43973     0.0.0.0:*               LISTEN      516171/python       
tcp6       0      0 :::44781                :::*                    LISTEN      516171/python       
可以看出来,它在39257端口上进行侦听

in openai/_base_client.py,model:qwen2-vl-instruct,remain_retries:2
in openai/_base_client.py,response:<Response [500 Internal Server Error]>,response.content:b'{"detail":"[address=0.0.0.0:39257, pid=516171] You set image=2 (or defaulted to 1) in `--limit-mm-per-prompt`, but found 3 items in the same prompt."}'
in openai/_base_client.py,model:qwen2-vl-instruct,remain_retries:1
in openai/_base_client.py,response:<Response [500 Internal Server Error]>,response.content:b'{"detail":"Remote server 0.0.0.0:39257 closed"}'
in openai/_base_client.py,model:qwen2-vl-instruct,remain_retries:0
in openai/_base_client.py,response:<Response [400 Bad Request]>,response.content:b'{"detail":"[address=0.0.0.0:23015, pid=8661] Model not found, uid: qwen2-vl-instruct-1-0"}'

可以看到尝试了3次,model worker 进程是在39257上进行侦听的,并且这个worker 已经死掉了,咱们再看下目前的model worker 是谁,侦听端口号是哪些

 0   N/A  N/A    516875      C   ...naconda3/envs/xinference/bin/python    16008MiB 

tcp        0      0 0.0.0.0:43461           0.0.0.0:*               LISTEN      516875/python       
tcp        0      0 10.18.120.185:37921     0.0.0.0:*               LISTEN      516875/python       
tcp        0      0 10.18.120.185:40091     0.0.0.0:*               LISTEN      516875/python       
tcp        0      0 10.18.120.185:36551     0.0.0.0:*               LISTEN      516875/python       
tcp6       0      0 :::55813                :::*                    LISTEN      516875/python       

进程号和侦听端口已全部换成新的,那么这个问题基本已经明朗了

总共请求次数3次

第一次请求,由于xinference model worker 无法处理我的prompt,所以报错,在此时model worker 由于出错正在关闭进程中

第二次请求,由于model worker 已经属于关闭的状态,所以报model worker closed 错误

第三次请求,目前没有model worker,xinference 在端口23015上寻找model worker 找不到,所以返回了这个错误,而且同时model worker 正在重启,由于加载模型较慢,还没完成重启过程

由于重试3次,最后报的错误的是第三次,并且每次的错误都不一样,第一次的错误才是最真实的错误,所以比较难区分。

xinference 可能是对prompt 进行了检查和分析,所以报了第一个错误,同时它还对其他的prompt 进行了分析,之前也遇到过

解决办法:按照第一个错误的提示,按照参考资料3,launch 模型时,设置参数--limit-mm-per-prompt 为10,再试一次

发现已经可以正常返回

参考资料:

调用 Xinference OpenAI接口时报错 Model not found in the model list, uid_xinference model not found in the model list-优快云博客

GitHub · Where software is built 

Xinference prompt图片限制数量的解决办法_you set image=1 (or defaulted to 1) in `--limit-mm-优快云博客

本文章已经生成可运行项目
2025-10-13 05:38:10.126 INFO [Dummy-6] [_client.py:1038] - HTTP Request: POST https://marketplace.dify.ai/api/v1/plugins/batch "HTTP/1.1 200 OK" 2025-10-13 05:41:06.161 WARNING [Dummy-7] [version.py:66] - Check update version error: httpx.Timeout must either include a default, or set all four parameters explicitly.. 2025-10-13 05:41:53.220 INFO [Dummy-8] [_client.py:1038] - HTTP Request: GET https://marketplace.dify.ai/api/v1/plugins/download?unique_identifier=langgenius/json_process:0.0.2@dde6d7b676ccdcea89206d29232181a840170c19277d3d978e27cd1e3c92c707 "HTTP/1.1 200 OK" 2025-10-13 05:41:53.273 INFO [Dummy-9] [_client.py:1038] - HTTP Request: GET https://marketplace.dify.ai/api/v1/plugins/download?unique_identifier=langgenius/json_process:0.0.2@dde6d7b676ccdcea89206d29232181a840170c19277d3d978e27cd1e3c92c707 "HTTP/1.1 200 OK" 2025-10-13 05:42:56.742 INFO [Dummy-10] [_client.py:1038] - HTTP Request: GET https://marketplace.dify.ai/api/v1/plugins/download?unique_identifier=bowenliang123/md_exporter:2.0.0@13e1aca1995328e41c080ff9f7f6d898df60ff74a3f4d98d6de4b18ab5b92c2e "HTTP/1.1 200 OK" 2025-10-13 05:42:58.576 INFO [Dummy-11] [_client.py:1038] - HTTP Request: GET https://marketplace.dify.ai/api/v1/plugins/download?unique_identifier=bowenliang123/md_exporter:2.0.0@13e1aca1995328e41c080ff9f7f6d898df60ff74a3f4d98d6de4b18ab5b92c2e "HTTP/1.1 200 OK" 2025-10-13 05:45:36.759 WARNING [Dummy-12] [version.py:66] - Check update version error: httpx.Timeout must either include a default, or set all four parameters explicitly.. 2025-10-13 05:46:47.202 WARNING [Dummy-13] [version.py:66] - Check update version error: httpx.Timeout must either include a default, or set all four parameters explicitly.. 2025-10-13 05:46:55.577 INFO [Dummy-14] [_client.py:1038] - HTTP Request: POST https://marketplace.dify.ai/api/v1/plugins/batch "HTTP/1.1 200 OK" 2025-10-13 05:47:26.786 ERROR [Dummy-15] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\\"args\\":{},\\"error_type\\":\\"CredentialsValidateFailedError\\",\\"message\\":\\"Xinference credentials validate failed: get xinference model extra parameter failed, status code: 400, response: {\\\\\\"detail\\\\\\":\\\\\\"[address=0.0.0.0:13143, pid=97] Model not found in the model list, uid: bge-reranker-v2-m3-0\\\\\\"}\\"}","error_type":"PluginInvokeError","args":null}', 'data': None} 2025-10-13 05:47:26.788 ERROR [Dummy-15] [models.py:287] - Failed to save model credentials, tenant_id: cbf2f404-1039-4c79-a5ea-83e90db08045, model: bge-reranker-v2-m3, model_type: llm Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 278, in post model_provider_service.create_model_credential( File "/app/api/services/model_provider_service.py", line 263, in create_model_credential provider_configuration.create_custom_model_credential( File "/app/api/core/entities/provider_configuration.py", line 928, in create_custom_model_credential credentials = self.validate_custom_model_credentials( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 901, in validate_custom_model_credentials return _validate(session) ^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 890, in _validate validated_credentials = model_provider_factory.model_credentials_validate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 156, in model_credentials_validate self.plugin_model_manager.validate_model_credentials( File "/app/api/core/plugin/impl/model.py", line 137, in validate_model_credentials for resp in response: ^^^^^^^^ File "/app/api/core/plugin/impl/base.py", line 212, in _request_with_plugin_daemon_response_stream self._handle_plugin_daemon_error(error.error_type, error.message) File "/app/api/core/plugin/impl/base.py", line 242, in _handle_plugin_daemon_error raise CredentialsValidateFailedError(error_object.get("message")) core.model_runtime.errors.validate.CredentialsValidateFailedError: Xinference credentials validate failed: get xinference model extra parameter failed, status code: 400, response: {"detail":"[address=0.0.0.0:13143, pid=97] Model not found in the model list, uid: bge-reranker-v2-m3-0"} 2025-10-13 05:47:32.662 ERROR [Dummy-16] [base.py:211] - Error in stream reponse for plugin {'code': -500, 'message': '{"message":"{\\"args\\":{},\\"error_type\\":\\"CredentialsValidateFailedError\\",\\"message\\":\\"Xinference credentials validate failed: get xinference model extra parameter failed, status code: 400, response: {\\\\\\"detail\\\\\\":\\\\\\"[address=0.0.0.0:13143, pid=97] Model not found in the model list, uid: bge-reranker-v2-m3-0\\\\\\"}\\"}","error_type":"PluginInvokeError","args":null}', 'data': None} 2025-10-13 05:47:32.664 ERROR [Dummy-16] [models.py:287] - Failed to save model credentials, tenant_id: cbf2f404-1039-4c79-a5ea-83e90db08045, model: bge-reranker-v2-m3, model_type: llm Traceback (most recent call last): File "/app/api/controllers/console/workspace/models.py", line 278, in post model_provider_service.create_model_credential( File "/app/api/services/model_provider_service.py", line 263, in create_model_credential provider_configuration.create_custom_model_credential( File "/app/api/core/entities/provider_configuration.py", line 928, in create_custom_model_credential credentials = self.validate_custom_model_credentials( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 901, in validate_custom_model_credentials return _validate(session) ^^^^^^^^^^^^^^^^^^ File "/app/api/core/entities/provider_configuration.py", line 890, in _validate validated_credentials = model_provider_factory.model_credentials_validate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/api/core/model_runtime/model_providers/model_provider_factory.py", line 156, in model_credentials_validate self.plugin_model_manager.validate_model_credentials( File "/app/api/core/plugin/impl/model.py", line 137, in validate_model_credentials for resp in response: ^^^^^^^^ File "/app/api/core/plugin/impl/base.py", line 212, in _request_with_plugin_daemon_response_stream self._handle_plugin_daemon_error(error.error_type, error.message) File "/app/api/core/plugin/impl/base.py", line 242, in _handle_plugin_daemon_error raise CredentialsValidateFailedError(error_object.get("message")) core.model_runtime.errors.validate.CredentialsValidateFailedError: Xinference credentials validate failed: get xinference model extra parameter failed, status code: 400, response: {"detail":"[address=0.0.0.0:13143, pid=97] Model not found in the model list, uid: bge-reranker-v2-m3-0"} /app/api/.venv/lib/python3.12/site-packages/pypdfium2/_helpers/textpage.py:80: UserWarning: get_text_range() call with default params will be implicitly redirected to get_text_bounded() warnings.warn("get_text_range() call with default params will be implicitly redirected to get_text_bounded()") 2025-10-13 05:50:22.776 WARNING [GraphDispatcher] [event_handlers.py:102] - Unhandled event type: NodeRunRetrieverResourceEvent 2025-10-13 05:53:02.835 WARNING [GraphDispatcher] [event_handlers.py:102] - Unhandled event type: NodeRunRetrieverResourceEvent 2025-10-13 08:20:24.675 WARNING [Dummy-21] [version.py:66] - Check update version error: httpx.Timeout must either include a default, or set all four parameters explicitly.. 2025-10-13 08:21:09.384 INFO [Dummy-22] [_client.py:1038] - HTTP Request: POST https://marketplace.dify.ai/api/v1/plugins/batch "HTTP/1.1 200 OK"
最新发布
10-14
<think>好的,我现在需要解决用户在部署Xinference模型时遇到的503错误,提示“No available slot for model”。首先,我得理解这个错误的原因。根据错误信息,可能是指当前服务器没有可用的资源槽位来加载新模型,也就是说资源已经被占满了。 首先,我应该考虑资源限制的问题。用户可能同时部署了多个模型,或者当前模型的资源需求超过了服务器的可用资源。比如,内存或显存不足。这时候需要检查服务器的资源使用情况,使用像nvidia-smi或者htop这样的工具查看GPU和CPU的使用率,确认是否有足够的内存和显存来加载新模型。 接下来,可能需要调整Xinference的配置。Xinference允许设置每个模型的资源限制,比如CPU核心数、内存大小,或者GPU的数量。用户可能没有正确配置这些参数,导致资源被过度占用。比如,可以通过设置--num-threads或者--gpu来限制每个模型使用的资源,确保有足够的资源槽位。 另外,并发请求也是一个可能的原因。如果服务器同时处理多个请求,而配置的最大并发数太低,可能会导致503错误。这时候需要检查Xinference的并发设置,适当增加最大并发模型加载的数量。例如,修改配置文件中的max_concurrent_models参数,或者启动服务器时指定--max-concurrent参数。 还有可能是已经部署的模型没有正确释放资源。用户可能之前部署过模型但没有停止,导致资源一直被占用。这时候需要列出当前所有运行的模型,停止不再需要的模型。使用xinference list命令查看,然后使用xinference terminate来释放资源。 最后,如果以上方法都不行,可能需要考虑升级Xinference版本或者联系开发者,因为可能遇到了已知的bug。用户应该检查是否有新版本发布,并查看官方文档或社区是否有相关的解决方案。 在解决过程中,参考了类似SP Flash Tool错误处理的方法,比如通过检查资源限制和调整配置来解决问题[^1]。此外,类似于调整RC通道的数值来控制系统行为,合理分配资源也是关键[^2]。</think>### 如何解决Xinference模型部署时的503错误(No available slot for model) #### 1. **检查资源占用情况** - **问题分析**:错误提示“无可用槽位”通常表示服务器资源(如内存、显存或CPU)已被占满,无法分配新模型的加载。 - **解决步骤**: 1. 使用命令行工具(如`htop`、`nvidia-smi`)查看当前CPU/GPU和内存使用情况。 2. 若资源占用过高,需停止部分已部署的模型。通过以下命令查看已加载模型: ```bash xinference list ``` 3. 终止不需要的模型: ```bash xinference terminate --model-uid <model_uid> ``` #### 2. **调整Xinference资源配置** - **问题分析**:Xinference默认可能未合理分配资源,导致槽位不足。 - **解决步骤**: 1. 启动Xinference时指定资源限制,例如限制单模型的CPU核心数或内存: ```bash xinference-local --max-concurrent 5 --memory 8G ``` 2. 部署模型时显式指定资源参数(如CPU/GPU配额): ```bash xinference launch --model-name <model_name> --num-threads 2 --gpu 0 ``` #### 3. **优化并发设置** - **问题分析**:服务器并发加载模型的默认数量可能过低。 - **解决步骤**: 1. 修改Xinference配置文件(如`config.yaml`),增加`max_concurrent_models`的值。 2. 若以命令行启动,直接指定并发数: ```bash xinference-local --max-concurrent 10 ``` #### 4. **检查模型依赖和版本兼容性** - **问题分析**:某些模型可能需要特定版本的依赖库,冲突可能导致资源分配失败。 - **解决步骤**: 1. 确保Xinference版本与模型要求的依赖库(如PyTorch、Transformers)兼容。 2. 更新Xinference至最新版本: ```bash pip install -U xinference ``` #### 5. **参考类似问题的解决方案** - 类似资源分配问题可通过“分段排查”解决,例如通过日志定位具体阻塞点[^1]。 - 调整资源配置时,可借鉴硬件控制逻辑(如RC通道的数值分配原理,通过参数微调优化资源利用率)[^2]。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值