binary-husky/gpt_academic · critical · RuntimeError
不能正常加载MOSS的参数!
Error message
不能正常加载MOSS的参数!
What it means
Raised in the MOSS loader thread when self.moss_init() throws: the code first validate_path()s into request_llms/moss, then the bare except sends '[Local Message] Call MOSS fail' to the parent and raises RuntimeError('不能正常加载MOSS的参数!'). Root causes (missing weights, transformers version mismatch, CUDA OOM) are discarded.
Source
Thrown at request_llms/bridge_moss.py:119
"""
self.prompt = self.meta_instruction
self.local_history = []
def run(self): # 子进程执行
# 子进程执行
# 第一次运行,加载参数
def validate_path():
import os, sys
root_dir_assume = os.path.abspath(os.path.dirname(__file__) + '/..')
os.chdir(root_dir_assume + '/request_llms/moss')
sys.path.append(root_dir_assume + '/request_llms/moss')
validate_path() # validate path so you can run from base directory
try:
self.moss_init()
except:
self.child.send('[Local Message] Call MOSS fail 不能正常加载MOSS的参数。')
raise RuntimeError("不能正常加载MOSS的参数!")
# 进入任务等待状态
# 这段代码来源 https://github.com/OpenLMLab/MOSS/blob/main/moss_cli_demo.py
import torch
while True:
# 等待输入
kwargs = self.child.recv() # query = input("<|Human|>: ")
try:
query = kwargs['query']
history = kwargs['history']
sys_prompt = kwargs['sys_prompt']
if len(self.local_history) > 0 and len(history)==0:
self.prompt = self.meta_instruction
self.local_history.append(query)
self.prompt += '<|Human|>: ' + query + '<eoh>'
inputs = self.tokenizer(self.prompt, return_tensors="pt")
with torch.no_grad():
outputs = self.model.generate(View on GitHub (pinned to d6bde0fa54)
Solutions
- Reproduce outside the thread: chdir to request_llms/moss and call the same moss_init logic to see the real traceback.
- Fetch the MOSS weights/config exactly as request_llms/bridge_moss.py documents and pin the required transformers/torch versions.
- Check GPU memory and LOCAL_MODEL_DEVICE; MOSS needs tens of GB VRAM (or quantization).
- MOSS is unmaintained — prefer a maintained local backend if it cannot load.
Defensive patterns
Strategy: validation
Validate before calling
def moss_loadable() -> bool:
import os
return os.path.isdir(os.path.join(ROOT, 'request_llms', 'moss')) # weights dir present
# gate the MOSS entry on moss_loadable() plus a dry import of moss_init deps Try / catch
try:
handle = GetGLMHandle()
except RuntimeError as e:
if 'MOSS' in str(e):
log.error('MOSS load failed: %s', e) Prevention
- Pre-download MOSS weights; pin transformers/torch versions
- Verify VRAM fits MOSS before selecting it
- Smoke-test moss_init standalone at startup
When it happens
Trigger: First use of the local MOSS model: moss_init fails to load the MOSS weights/config (missing moss-github checkout, failed download, transformers or torch version incompatible, insufficient GPU memory).
Common situations: Fresh clone without the MOSS model files, old transformers version incompatible with MOSS modeling code, LOCAL_MODEL_DEVICE=cuda on a CPU box, GPU with too little VRAM.
Related errors
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/f83db06e4f596337.
Report an issue: GitHub.