1

I’m trying to debug my Python code with debugpy in VS Code on WSL (Ubuntu).

Environment:

  • Python: 3.12.3 (venv)

  • vLLM: 0.10.1.1+cpu

  • debugpy: ms-python.debugpy-2025.10.0 (from VS Code extension)

  • Model: Tiny LLM downloaded from Hugging Face

  • Running inside WSL2 (Ubuntu)

Code (run-model.py):

from vllm import LLM, SamplingParams

def main():
    llm = LLM(model="./Tiny-LLM")
    params = SamplingParams(temperature=0.7, max_tokens=200)
    prompt = "Once upon a time in a magical forest,"

    for output in llm.generate([prompt], sampling_params=params):
        print(output.outputs[0].text)

if __name__ == "__main__":
    main()

When I run this script normally in the terminal, it works and generates text.

But when I run it with debugpy in VS Code, I get:

AttributeError: module 'ray' has no attribute 'is_initialized'

Traceback (excerpt):

  File ".../vllm/engine/arg_utils.py", line 1127, in create_engine_config
if is_ray_initialized():
  File ".../vllm/ray/lazy_utils.py", line 9, in is_ray_initialized
return ray.is_initialized()
AttributeError: module 'ray' has no attribute 'is_initialized'

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug run-model.py with vllm",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceFolder}/run-model.py",
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}",
            "justMyCode": false,
            "env": {
                "VLLM_TARGET_DEVICE": "cpu",
                "PYTHONPATH": "${workspaceFolder}/../vllm"
            }
        }
    ]
}

What I’ve tried so far:

  • Verified that the model loads and runs outside of debugpy (works fine).
  • Installed and reinstalled different Ray versions (2.9.3, 2.49.1, etc.) — same error.
  • Checked that ray.is_initialized() exists when I import ray directly in Python (works outside vLLM).
  • Tried running debugpy both in integratedTerminal and externalTerminal.
  • Explicitly set environment variables (VLLM_TARGET_DEVICE=cpu, PYTHONPATH=...) in launch.json.

Questions:

  1. Why does vLLM call ray.is_initialized() only when running under debugpy?
  2. Is this a Ray version mismatch, or something about vLLM’s CPU mode with debugpy?
  3. What’s the correct way to set up debugpy with vLLM on CPU in WSL?

1 Answer 1

1

The traceback shows the failure at vllm/ray/lazy_utils.py on line 9: return ray.is_initialized().

A simple workaround would be to wrap the problematic line in a try...except block to handle the AttributeError. Something like:

Python

# File: .../vllm/ray/lazy_utils.py

import ray

def is_ray_initialized():
    try:
        return ray.is_initialized()
    except AttributeError:
        return False
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.