binary-husky/gpt_academic · critical · RuntimeError

不能正常加载{self.model_name}的参数!

Error message

不能正常加载{self.model_name}的参数!

What it means

In the local-LLM loader subprocess, any exception while calling load_model_and_tokenizer (model download, transformers/vllm init, out-of-memory) is caught, reported to the parent process via self.child.send with a trimmed traceback, and then re-raised as RuntimeError('不能正常加载{model}的参数!'). The generic raise masks the original cause, so the child message with the real traceback is the useful artifact.

Source

Thrown at request_llms/local_llm_class.py:152

    def run(self):
        # 🏃‍♂️🏃‍♂️🏃‍♂️ run in child process
        # 第一次运行,加载参数
        self.child.flush = lambda *args: None
        self.child.write = lambda x: self.child.send(self.std_tag + x)
        reset_tqdm_output()
        self.set_state("`尝试加载模型`")
        try:
            with redirect_stdout(self.child):
                self._model, self._tokenizer = self.load_model_and_tokenizer()
        except:
            self.set_state("`加载模型失败`")
            self.running = False
            from toolbox import trimmed_format_exc
            self.child.send(
                f'[Local Message] 不能正常加载{self.model_name}的参数.' + '\n```\n' + trimmed_format_exc() + '\n```\n')
            self.child.send('[FinishBad]')
            raise RuntimeError(f"不能正常加载{self.model_name}的参数!")

        self.set_state("`准备就绪`")
        while True:
            # 进入任务等待状态
            kwargs = self.child.recv()
            # 收到消息,开始请求
            try:
                for response_full in self.llm_stream_generator(**kwargs):
                    self.child.send(response_full)
                    # print('debug' + response_full)
                self.child.send('[Finish]')
                # 请求处理结束,开始下一个循环
            except:
                from toolbox import trimmed_format_exc
                self.child.send(
                    f'[Local Message] 调用{self.model_name}失败.' + '\n```\n' + trimmed_format_exc() + '\n```\n')
                self.child.send('[Finish]')

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Check the chatbot/child-process message: it embeds trimmed_format_exc() with the original traceback — read it to find the true cause.
  2. Verify the local model path in config.py exists and contains config.json/weights; fix the path or re-download.
  3. Free GPU memory (close other processes, pick a smaller quantization) if the underlying error is CUDA OOM.
  4. Pin/downgrade transformers (and related libs) to versions the model card requires.

Example fix

# before
except:
    ...
    raise RuntimeError(f"不能正常加载{self.model_name}的参数!")

# after: chain the original exception
except Exception:
    self.set_state("`加载模型失败`")
    self.running = False
    from toolbox import trimmed_format_exc
    self.child.send(f'[Local Message] 不能正常加载{self.model_name}的参数.' + '\n```\n' + trimmed_format_exc() + '\n```\n')
    self.child.send('[FinishBad]')
    raise RuntimeError(f"不能正常加载{self.model_name}的参数!") from e
Defensive patterns

Strategy: try-catch

Try / catch

try:
    handle = spawn_local_model(...)
except RuntimeError as e:
    # the child message piped into chatbot contains the real traceback
    if '不能正常加载' in str(e):
        show_loader_traceback(); suggest_memory_or_path_fix()

Prevention

When it happens

Trigger: Instantiating a local model singleton (e.g. qwen/local model via get_local_llm_predict_fns) when model weights cannot be downloaded or loaded: bad model path in config, transformers version mismatch, CUDA OOM, no network to HuggingFace, or wrong trust_remote_code settings.

Common situations: First run of a local model with insufficient VRAM/RAM; model_name_or_path pointing to a nonexistent local directory; corporate proxy blocking HF downloads; recent transformers release dropping support for a legacy model class.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/a4ce340266251748. Report an issue: GitHub.