5.6. Python 多处理错误


  • 您可能会遇到 Python 多处理警告或运行时错误。这可能是由没有为 Python 多处理正确构建的代码导致。以下是控制台警告示例:

    WARNING 12-11 14:50:37 multiproc_worker_utils.py:281] CUDA was previously
        initialized. We must use the `spawn` multiprocessing start method. Setting
        VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. See
        https://docs.vllm.ai/en/latest/getting_started/troubleshooting.html#python-multiprocessing
        for more information.
    Copy to Clipboard Toggle word wrap

    以下是 Python 运行时错误示例:

    RuntimeError:
            An attempt has been made to start a new process before the
            current process has finished its bootstrapping phase.
    
            This probably means that you are not using fork to start your
            child processes and you have forgotten to use the proper idiom
            in the main module:
    
                if __name__ = "__main__":
                    freeze_support()
                    ...
    
            The "freeze_support()" line can be omitted if the program
            is not going to be frozen to produce an executable.
    
            To fix this issue, refer to the "Safe importing of main module"
            section in https://docs.python.org/3/library/multiprocessing.html
    Copy to Clipboard Toggle word wrap

    要解决运行时错误,请更新您的 Python 代码,以保护 if__name__ = "__main__": 块后面的 vllm 的使用,例如:

    if __name__ = "__main__":
        import vllm
    
        llm = vllm.LLM(...)
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat