Skip to content

[Bug]: 100% CPU usage when idle. While loop in acquire_read pegging the CPU. #19036

Closed
@MathieuBordere

Description

@MathieuBordere

Your current environment

The output of python collect_env.py
(vllm-dev) mathieu@sophia:vllm $ python collect_env.py
INFO 06-02 20:48:21 [__init__.py:243] Automatically detected platform cuda.
Collecting environment information...
==============================
        System Info
==============================
OS                           : Fedora Linux 42 (Workstation Edition) (x86_64)
GCC version                  : (GCC) 15.1.1 20250521 (Red Hat 15.1.1-2)
Clang version                : 20.1.5 (Fedora 20.1.5-1.fc42)
CMake version                : version 3.31.6
Libc version                 : glibc-2.41

==============================
       PyTorch Info
==============================
PyTorch version              : 2.7.0+cu126
Is debug build               : False
CUDA used to build PyTorch   : 12.6
ROCM used to build PyTorch   : N/A

==============================
      Python Environment
==============================
Python version               : 3.12.10 | packaged by conda-forge | (main, Apr 10 2025, 22:21:13) [GCC 13.3.0] (64-bit runtime)
Python platform              : Linux-6.14.9-300.fc42.x86_64-x86_64-with-glibc2.41

==============================
       CUDA / GPU Info
==============================
Is CUDA available            : True
CUDA runtime version         : Could not collect
CUDA_MODULE_LOADING set to   : LAZY
GPU models and configuration :
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090

Nvidia driver version        : 570.153.02
cuDNN version                : Probably one of the following:
/usr/lib64/libcudnn.so.9.10.0
/usr/lib64/libcudnn_adv.so.9.10.0
/usr/lib64/libcudnn_cnn.so.9.10.0
/usr/lib64/libcudnn_engines_precompiled.so.9.10.0
/usr/lib64/libcudnn_engines_runtime_compiled.so.9.10.0
/usr/lib64/libcudnn_graph.so.9.10.0
/usr/lib64/libcudnn_heuristic.so.9.10.0
/usr/lib64/libcudnn_ops.so.9.10.0
HIP runtime version          : N/A
MIOpen runtime version       : N/A
Is XNNPACK available         : True

==============================
          CPU Info
==============================
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           48 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  24
On-line CPU(s) list:                     0-23
Vendor ID:                               AuthenticAMD
Model name:                              AMD Ryzen 9 7900 12-Core Processor
CPU family:                              25
Model:                                   97
Thread(s) per core:                      2
Core(s) per socket:                      12
Socket(s):                               1
Stepping:                                2
Frequency boost:                         enabled
CPU(s) scaling MHz:                      85%
CPU max MHz:                             5485,0000
CPU min MHz:                             545,0000
BogoMIPS:                                7399,81
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d amd_lbr_pmc_freeze
Virtualization:                          AMD-V
L1d cache:                               384 KiB (12 instances)
L1i cache:                               384 KiB (12 instances)
L2 cache:                                12 MiB (12 instances)
L3 cache:                                64 MiB (2 instances)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-23
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Mitigation; Safe RET
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsx async abort:           Not affected

==============================
Versions of relevant libraries
==============================
[pip3] numpy==2.2.6
[pip3] nvidia-cublas-cu12==12.6.4.1
[pip3] nvidia-cuda-cupti-cu12==12.6.80
[pip3] nvidia-cuda-nvrtc-cu12==12.6.77
[pip3] nvidia-cuda-runtime-cu12==12.6.77
[pip3] nvidia-cudnn-cu12==9.5.1.17
[pip3] nvidia-cufft-cu12==11.3.0.4
[pip3] nvidia-cufile-cu12==1.11.1.6
[pip3] nvidia-curand-cu12==10.3.7.77
[pip3] nvidia-cusolver-cu12==11.7.1.2
[pip3] nvidia-cusparse-cu12==12.5.4.2
[pip3] nvidia-cusparselt-cu12==0.6.3
[pip3] nvidia-nccl-cu12==2.26.2
[pip3] nvidia-nvjitlink-cu12==12.6.85
[pip3] nvidia-nvtx-cu12==12.6.77
[pip3] pyzmq==26.4.0
[pip3] torch==2.7.0
[pip3] torchaudio==2.7.0
[pip3] torchvision==0.22.0
[pip3] transformers==4.52.4
[pip3] triton==3.3.0
[conda] Could not collect

==============================
         vLLM Info
==============================
ROCM Version                 : 6.3.42133-0
Neuron SDK Version           : N/A
vLLM Version                 : 0.9.1.dev243+gca2f6b9c3 (git sha: ca2f6b9c3)
vLLM Build Flags:
  CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
        GPU0    GPU1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      PHB     0-23    0               N/A
GPU1    PHB      X      0-23    0               N/A

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

==============================
     Environment Variables
==============================
NCCL_CUMEM_ENABLE=0
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
CUDA_MODULE_LOADING=LAZY

🐛 Describe the bug

Running vllm serve "deepseek-ai/DeepSeek-R1-0528-Qwen3-8B" --tensor-parallel-size 2 results in 2 python processes taking up 100% each of a CPU while vllm is idle.

py-spy top output of one of the offending processes

GIL: 49.00%, Active: 100.00%, Threads: 5

  %Own   %Total  OwnTime  TotalTime  Function (filename)
 54.00%  54.00%    5.03s     5.03s   sched_yield (vllm/distributed/utils.py)
 14.00% 100.00%    1.09s     8.95s   acquire_read (vllm/distributed/device_communicators/shm_broadcast.py)
 12.00%  13.00%    1.04s     1.09s   get_metadata (vllm/distributed/device_communicators/shm_broadcast.py)
  5.00%   5.00%   0.590s    0.670s   __init__ (contextlib.py)
  6.00% 100.00%   0.410s     8.95s   __enter__ (contextlib.py)
  3.00%   4.00%   0.380s    0.400s   __exit__ (contextlib.py)
  5.00%  10.00%   0.360s     1.03s   helper (contextlib.py)
  1.00%   1.00%   0.050s    0.050s   buf (multiprocessing/shared_memory.py)
  0.00% 100.00%   0.000s     8.95s   dequeue (vllm/distributed/device_communicators/shm_broadcast.py)
  0.00% 100.00%   0.000s     8.95s   worker_main (vllm/v1/executor/multiproc_executor.py)
  0.00% 100.00%   0.000s     8.95s   worker_busy_loop (vllm/v1/executor/multiproc_executor.py)
  0.00% 100.00%   0.000s     8.95s   <module> (<string>)
  0.00% 100.00%   0.000s     8.95s   run (multiprocessing/process.py)
  0.00% 100.00%   0.000s     8.95s   _main (multiprocessing/spawn.py)
  0.00% 100.00%   0.000s     8.95s   _bootstrap (multiprocessing/process.py)

It looks like sched_yield tries to yield the CPU, but there's no other process that wants the CPU, so the loop in acquire_read runs again and sched_yield is called again, pegging the CPU.

Replacing the implementation of sched_yield with just a time.sleep(0.0001) call decreases the CPU usage to something like 2% on my system, but that implementation might be too naive?

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions