ThinkFacility

Error messages

RuntimeError: Cannot re-initialize CUDA in forked subprocess

The message

RuntimeError: Cannot re-initialize CUDA in forked subprocess
vLLM 0.30.0 read September 26, 2026vLLMPyTorchCUDA

What it means

Your Python process had already started using the GPU when vLLM copied it to make a worker. PyTorch won't let a copied process use the GPU, so the worker dies on its first CUDA call.

What to do

Don't touch CUDA before creating the vLLM engine (pick GPUs with CUDA_VISIBLE_DEVICES), or set VLLM_WORKER_MULTIPROC_METHOD=spawn and put your code under if __name__ == '__main__':.

vLLM starts loading, then a worker process falls over with a traceback that ends:

RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

The text is PyTorch's (it's still there in PyTorch 2.14.0), and vLLM hits it more than most libraries because it splits itself across several processes. 34 issues in the vLLM repo quote it as of September 26, 2026, and several of the recent ones come from vLLM's own automated tests.

What fork and spawn mean here

Python can start a child process two ways. Fork makes an instant copy of the running process, memory and all. Spawn starts a fresh Python and re-imports your script. Fork is faster and it's vLLM's default (VLLM_WORKER_MULTIPROC_METHOD defaults to fork in 0.30.0).

The catch is the GPU. Once a process has set up CUDA, a forked copy inherits a half-copied GPU state it can't safely use, so PyTorch refuses and raises this error the moment the child tries.

What vLLM already does about it

We read vLLM 0.30.0. Before starting workers it checks whether CUDA is already set up in the parent (and a few other cases, such as running under WSL or inside Ray) and, if so, switches to spawn by itself. You'll see a warning that begins We must use the `spawn` multiprocessing start method. Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'. and lists the reason.

So when the error still appears, something slipped past that check. The vLLM docs name the common one: calling GPU functions yourself (their example is torch.accelerator.set_device_index) before creating the engine. Add-ons that bring their own process handling can trip it too, as in #29591 with the LMCache example.

How to fix it

First, move any GPU work to after the LLM(...) or engine is created. If you were only choosing which cards to use, set CUDA_VISIBLE_DEVICES in the environment instead, which is what the docs recommend.

Second, force spawn from the start:

export VLLM_WORKER_MULTIPROC_METHOD=spawn

Spawn re-imports your script in each child, so a script with vLLM calls at the top level will try to start the engine again inside every worker. vLLM's troubleshooting page covers this. The symptom is a different RuntimeError, "An attempt has been made to start a new process before the current process has finished its bootstrapping phase", and the fix is to wrap your code:

if __name__ == '__main__':
    import vllm

    llm = vllm.LLM(...)

That example is copied from the docs, and it's the whole change: imports and engine creation move inside the guard.

If you're using vllm serve and never wrote any Python, the error points at vLLM itself or something it loaded. Update vLLM, then search the issues with the name of whichever extension or flag you've added.

Other lines the same feature prints

Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.

  • Cannot re-initialize CUDA in forked subprocess
  • RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
  • We must use the `spawn` multiprocessing start method. Overriding VLLM_WORKER_MULTIPROC_METHOD to 'spawn'.