我通过函数计算FC 想搭建AI大语言模型API服务
现在服务部署后,调用一直报错,怎么处理?:
{"ErrorCode":"CAExited","ErrorMessage":"Function instance exited unexpectedly(code 1, message:operation not permitted) with start command ' '.\nLogs:with NAS, mount built-in files to /mnt/auto/llm\r\nMount /mnt/auto/llm/models to /llm/models\r\nMount /mnt/auto/llm/app to /llm/app\r\n/mnt/auto/llm/models/chatglm2-6b-int4\r\nTraceback (most recent call last):\r\n File \"/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py\", line 479, in load_state_dict\r\n return torch.load(checkpoint_file, map_location=map_location)\r\n File \"/opt/conda/lib/python3.10/site-packages/torch/serialization.py\", line 797, in load\r\n with _open_zipfile_reader(opened_file) as opened_zipfile:\r\n File \"/opt/conda/lib/python3.10/site-packages/torch/serialization.py\", line 283, in init\r\n super().init(torch._C.PyTorchFileReader(name_or_buffer))\r\nRuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py\", line 483, in load_state_dict\r\n if f.read(7) == \"version\":\r\n File \"/opt/conda/lib/python3.10/codecs.py\", line 322, in decode\r\n (result, consumed) = self._buffer_decode(data, self.errors, final)\r\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/llm/app/main.py\", line 5, in \u003cmodule\u003e\r\n uvicorn.run(\"server:app\", host=\"0.0.0.0\", port=PORT)\r\n File \"/opt/conda/lib/python3.10/site-packages/uvicorn/main.py\", line 587, in run\r\n server.run()\r\n File \"/opt/conda/lib/python3.10/site-packages/uvicorn/server.py\", line 61, in run\r\n return asyncio.run(self.serve(sockets=sockets))\r\n File \"/opt/conda/lib/python3.10/asyncio/runners.py\", line 44, in run\r\n return loop.run_until_complete(main)\r\n File \"/opt/conda/lib/python3.10/asyncio/base_events.py\", line 649, in run_until_complete\r\n return future.result()\r\n File \"/opt/conda/lib/python3.10/site-packages/uvicorn/server.py\", line 68, in serve\r\n config.load()\r\n File \"/opt/conda/lib/python3.10/site-packages/uvicorn/config.py\", line 467, in load\r\n self.loaded_app = import_from_string(self.app)\r\n File \"/opt/conda/lib/python3.10/site-packages/uvicorn/importer.py\", line 21, in import_from_string\r\n module = importlib.import_module(module_str)\r\n File \"/opt/conda/lib/python3.10/importlib/init.py\", line 126, in import_module\r\n return _bootstrap._gcd_import(name[level:], package, level)\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1050, in _gcd_import\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1027, in _find_and_load\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 1006, in _find_and_load_unlocked\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 688, in _load_unlocked\r\n File \"\u003cfrozen importlib._bootstrap_external\u003e\", line 883, in exec_module\r\n File \"\u003cfrozen importlib._bootstrap\u003e\", line 241, in _call_with_frames_removed\r\n File \"/built-in/app/server.py\", line 10, in \u003cmodule\u003e\r\n llm: BaseLLM = load_model()\r\n File \"/llm/app/model/llm.py\", line 37, in load_model\r\n return ChatGLM(**model_args)\r\n File \"/llm/app/model/chatglm.py\", line 41, in init\r\n model = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True).half().cuda()\r\n File \"/opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py\", line 511, in from_pretrained\r\n return model_class.from_pretrained(\r\n File \"/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py\", line 2805, in from_pretrained\r\n state_dict = load_state_dict(resolved_archive_file)\r\n File \"/opt/conda/lib/python3.10/site-packages/transformers/modeling_utils.py\", line 495, in load_state_dict\r\n raise OSError(\r\nOSError: Unable to load weights from pytorch checkpoint file for '/mnt/auto/llm/models/chatglm2-6b-int4/pytorch_model.bin' at '/mnt/auto/llm/models/chatglm2-6b-int4/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True."}
这个问题看起来像是由于模型文件没有正确加载导致的。根据错误信息,模型文件似乎存在一些问题,比如文件格式不正确或者文件损坏。你可以尝试以下方法来解决这个问题:
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。