Skip to content

[Bug] VLM cuda memory leak incur OOM #8902

Description

@WingEdge777

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

When serving a vlm (qwen2.5-vl-3b/7b/32b in my cases). The GPU memory keeps increasing until it gets cuda out of memory for the coming request.

Reproduction

Start server:

python -m sglang.launch_server --model-path Qwen2.5-VL-3B-Instruct --tp 1 --nnodes 1 --node-rank 0 --trust-remote-code --host 0.0.0.0 --port 30000

client code:

import openai


client = openai.Client(api_key="EMPTY", base_url="http://127.0.0.1:30000/v1")
model_name = client.models.list().data[0].id

sampling_params = {"max_tokens": 512, "temperature": 0}

url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png"
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "please describe this image"},
            {"type": "image_url", "image_url": {"url": url}},
        ]
    }
]

for idx in range(100):
    print(f"{idx} req")
    response = client.chat.completions.create(
        model=model_name,
        messages=messages,
        **sampling_params,
    )
    # time.sleep(0.5)

print(response)

Every 2~5 requests cause a memory occupation bump of 20 MB.

Environment

Python: 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0]
CUDA available: True
GPU 0,1,2,3: NVIDIA A10
GPU 0,1,2,3 Compute Capability: 8.6
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.6, V12.6.68
CUDA Driver Version: 470.161.03
PyTorch: 2.7.1+cu126
sglang: 0.4.9.post6
sgl_kernel: 0.2.7
flashinfer_python: 0.2.9rc2
triton: 3.3.1
transformers: 4.53.0
torchao: 0.9.0+cu126
numpy: 2.2.6
aiohttp: 3.12.14
fastapi: 0.116.1
hf_transfer: 0.1.9
huggingface_hub: 0.34.3
interegular: 0.3.3
modelscope: 1.28.0
orjson: 3.10.18
outlines: 0.1.11
packaging: 25.0
psutil: 7.0.0
pydantic: 2.11.7
python-multipart: 0.0.20
pyzmq: 27.0.0
uvicorn: 0.35.0
uvloop: 0.21.0
vllm: 0.9.0.1
xgrammar: 0.1.21
openai: 1.95.1
tiktoken: 0.9.0
anthropic: 0.57.1
litellm: 1.74.2
decord: 0.6.0
NVIDIA Topology:
GPU0 GPU1 GPU2 GPU3 mlx5_0 CPU Affinity NUMA Affinity
GPU0 X PHB SYS SYS SYS 0-117 0
GPU1 PHB X SYS SYS SYS 0-117 0
GPU2 SYS SYS X PHB SYS 118-235 1
GPU3 SYS SYS PHB X SYS 118-235 1
mlx5_0 SYS SYS SYS SYS X

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks

Hypervisor vendor: KVM

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions