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.以下是 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要解决运行时错误,请更新您的 Python 代码,以保护
if__name__ = "__main__":块后面的vllm的使用,例如:if __name__ = "__main__": import vllm llm = vllm.LLM(...)