机器学习PAI服务运行中了,但不可用,调用时报错?
[2024-03-06 11:38:11] ERROR: Exception in ASGI application
[2024-03-06 11:38:11] Traceback (most recent call last):
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
[2024-03-06 11:38:11] result = await app( # type: ignore[func-returns-value]
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
[2024-03-06 11:38:11] return await self.app(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 1054, in call
[2024-03-06 11:38:11] await super().call(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 123, in call
[2024-03-06 11:38:11] await self.middleware_stack(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 186, in call
[2024-03-06 11:38:11] raise exc
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 164, in call
[2024-03-06 11:38:11] await self.app(scope, receive, _send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 83, in call
[2024-03-06 11:38:11] await self.app(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 83, in call
[2024-03-06 11:38:11] await self.app(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 62, in call
[2024-03-06 11:38:11] await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
[2024-03-06 11:38:11] raise exc
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
[2024-03-06 11:38:11] await app(scope, receive, sender)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 758, in call
[2024-03-06 11:38:11] await self.middleware_stack(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 778, in app
[2024-03-06 11:38:11] await route.handle(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 299, in handle
[2024-03-06 11:38:11] await self.app(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 79, in app
[2024-03-06 11:38:11] await wrap_app_handling_exceptions(app, request)(scope, receive, send)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
[2024-03-06 11:38:11] raise exc
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
[2024-03-06 11:38:11] await app(scope, receive, sender)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 74, in app
[2024-03-06 11:38:11] response = await func(request)
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 299, in app
[2024-03-06 11:38:11] raise e
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 294, in app
[2024-03-06 11:38:11] raw_response = await run_endpoint_function(
[2024-03-06 11:38:11] File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 191, in run_endpoint_function
[2024-03-06 11:38:11] return await dependant.call(**values)
[2024-03-06 11:38:11] File "/code/ChatLLM-webui/webui/entrypoints/api_server.py", line 242, in chat_api
[2024-03-06 11:38:11] if cmd_opts.enable_lora:
[2024-03-06 11:38:11] AttributeError: 'Namespace' object has no attribute 'enable_lora'
我加了这个 现在起来了
从报错信息来看,问题出在api_server.py
文件的第242行,Namespace
对象没有enable_lora
属性。为了解决这个问题,你需要检查Namespace
对象的定义以及enable_lora
属性的设置。
首先,确保你在创建Namespace
对象时定义了enable_lora
属性。例如:
from argparse import Namespace
cmd_opts = Namespace(enable_lora=True)
然后,在第242行之前,确保你已经正确地设置了enable_lora
属性的值。例如:
if hasattr(cmd_opts, 'enable_lora'):
if cmd_opts.enable_lora:
# 你的代码逻辑
这样,当enable_lora
属性存在且值为True
时,才会执行相应的代码逻辑。
看着像是vllm在分配显存池的时候没有拿到足够的空间,试试设置下--gpu-memory-utilization,比如0.98 还有 --max-model-len,比如4096 ,此回答整理自钉群“机器学习PAI交流群(答疑@值班)”
看起来是在运行机器学习 PAI 服务时发生了错误。根据报错信息,似乎是在 api_server.py
文件的 chat_api
函数中,尝试访问一个名为 enable_lora
的属性时出现了问题。
可能的原因之一是 cmd_opts
对象没有 enable_lora
属性。你可以检查 cmd_opts
对象的定义或者在调用 chat_api
函数之前确保 cmd_opts
对象具有 enable_lora
属性。
另外,也可以检查代码中是否有其他地方在使用 cmd_opts.enable_lora
,确保相关的代码逻辑没有问题。
如果问题仍然存在,你可能需要进一步检查代码的其他部分,或者提供更多的代码上下文,以便更准确地确定问题的原因和解决方法。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
人工智能平台 PAI(Platform for AI,原机器学习平台PAI)是面向开发者和企业的机器学习/深度学习工程平台,提供包含数据标注、模型构建、模型训练、模型部署、推理优化在内的AI开发全链路服务,内置140+种优化算法,具备丰富的行业场景插件,为用户提供低门槛、高性能的云原生AI工程化能力。