vllm-project / vllm

A high-throughput and memory-efficient inference and serving engine for LLMs
https://docs.vllm.ai
Apache License 2.0
22.91k stars 3.24k forks source link

[Bug]: OOM when loading Qwen2 GPTQ 8bit and modify gpu_memory_utilization didn't help #5993

Open aabbccddwasd opened 2 weeks ago

aabbccddwasd commented 2 weeks ago

Your current environment

Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Clang version: Could not collect
CMake version: version 3.29.6
Libc version: glibc-2.35

Python version: 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] (64-bit runtime)
Python platform: Linux-6.5.0-41-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.66
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 2080 Ti
GPU 1: NVIDIA GeForce RTX 2080 Ti
GPU 2: NVIDIA GeForce RTX 2080 Ti
GPU 3: NVIDIA GeForce RTX 2080 Ti
GPU 4: NVIDIA GeForce RTX 2080 Ti

Nvidia driver version: 550.90.07
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      46 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             56
On-line CPU(s) list:                0-55
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
CPU family:                         6
Model:                              79
Thread(s) per core:                 2
Core(s) per socket:                 14
Socket(s):                          2
Stepping:                           1
CPU max MHz:                        3300.0000
CPU min MHz:                        1200.0000
BogoMIPS:                           4799.99
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts vnmi md_clear flush_l1d
Virtualization:                     VT-x
L1d cache:                          896 KiB (28 instances)
L1i cache:                          896 KiB (28 instances)
L2 cache:                           7 MiB (28 instances)
L3 cache:                           70 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-13,28-41
NUMA node1 CPU(s):                  14-27,42-55
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
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; Retpolines; IBPB conditional; IBRS_FW; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] transformers==4.42.3
[pip3] triton==2.3.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] torch                     2.3.0                    pypi_0    pypi
[conda] transformers              4.42.3                   pypi_0    pypi
[conda] triton                    2.3.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.0.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    GPU4    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  SYS SYS SYS SYS 0-13,28-41  0       N/A
GPU1    SYS  X  NV2 PHB PHB 14-27,42-55 1       N/A
GPU2    SYS NV2  X  PHB PHB 14-27,42-55 1       N/A
GPU3    SYS PHB PHB  X  NV2 14-27,42-55 1       N/A
GPU4    SYS PHB PHB NV2  X  14-27,42-55 1       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

🐛 Describe the bug

I set gpu_memory_utilization to 0.1 but before loading weights vllm already consumes 18.7G VRAM, near to 22GB * 0.9 = 19.8G, than when the weights were loaded ,22GB 2080ti got OOM

from vllm import LLM
import os

os.environ["CUDA_VISIBLE_DEVICES"] = "1,2,3,4"

if __name__ == "__main__":
    llm = LLM(model="../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8",
              tensor_parallel_size=4,
              swap_space=16,
              gpu_memory_utilization=0.1,
              enforce_eager=True)

I set gpu_memory_utilization to 0.1 but before loading weights vllm already consumes 18.7G VRAM, near to 22GB * 0.9 = 19.8G, than when the weights were loaded ,22GB 2080ti got OOM, I also tried python -m vllm.entrypoints.openai.api_server --model ../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8 --tensor-parallel-size=4 --gpu-memory-utilization 0.1 but it didn't work as well

Maybe it is not related to gpu_memory_utilization but when I load AWQ model and modify gpu_memory_utilization the VRAM actually consumed didn't change.So I guessed the problem is caused by gpu_memory_utilization

First it outputed this, than all of the output is OOM error WARNING 06-30 18:37:15 config.py:217] gptq quantization is not fully optimized yet. The speed can be slower than non-quantized models. 2024-06-30 18:37:15,586 INFO worker.py:1586 -- Connecting to existing Ray cluster at address: 192.168.3.123:6379... 2024-06-30 18:37:15,600 INFO worker.py:1771 -- Connected to Ray cluster. INFO 06-30 18:37:15 config.py:623] Defaulting to use mp for distributed inference WARNING 06-30 18:37:15 config.py:437] Possibly too large swap space. 64.00 GiB out of the 125.75 GiB total CPU memory is allocated for the swap space. INFO 06-30 18:37:15 llm_engine.py:161] Initializing an LLM engine (v0.5.0.post1) with config: model='../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8', speculative_config=None, tokenizer='../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, rope_scaling=None, rope_theta=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.float16, max_seq_len=32768, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=4, disable_custom_all_reduce=False, quantization=gptq, enforce_eager=True, kv_cache_dtype=auto, quantization_param_path=None, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='outlines'), seed=0, served_model_name=../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8) Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. INFO 06-30 18:37:16 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. INFO 06-30 18:37:16 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332366) INFO 06-30 18:37:18 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332366) INFO 06-30 18:37:18 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332367) INFO 06-30 18:37:18 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332367) INFO 06-30 18:37:18 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332365) INFO 06-30 18:37:18 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332365) INFO 06-30 18:37:18 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332366) INFO 06-30 18:37:19 multiproc_worker_utils.py:215] Worker ready; awaiting tasks (VllmWorkerProcess pid=332365) INFO 06-30 18:37:20 multiproc_worker_utils.py:215] Worker ready; awaiting tasks (VllmWorkerProcess pid=332367) INFO 06-30 18:37:20 multiproc_worker_utils.py:215] Worker ready; awaiting tasks (VllmWorkerProcess pid=332366) INFO 06-30 18:37:20 utils.py:637] Found nccl from library libnccl.so.2 (VllmWorkerProcess pid=332365) INFO 06-30 18:37:20 utils.py:637] Found nccl from library libnccl.so.2 (VllmWorkerProcess pid=332367) INFO 06-30 18:37:20 utils.py:637] Found nccl from library libnccl.so.2 (VllmWorkerProcess pid=332365) INFO 06-30 18:37:20 pynccl.py:63] vLLM is using nccl==2.20.5 (VllmWorkerProcess pid=332366) INFO 06-30 18:37:20 pynccl.py:63] vLLM is using nccl==2.20.5 (VllmWorkerProcess pid=332367) INFO 06-30 18:37:20 pynccl.py:63] vLLM is using nccl==2.20.5 INFO 06-30 18:37:20 utils.py:637] Found nccl from library libnccl.so.2 INFO 06-30 18:37:20 pynccl.py:63] vLLM is using nccl==2.20.5 Traceback (most recent call last): File "/home/aabbccddwasd/.conda/envs/obj013-env-vllm/lib/python3.10/multiprocessing/resource_tracker.py", line 209, in main cache[rtype].remove(name) KeyError: '/psm_15339bca' Traceback (most recent call last): File "/home/aabbccddwasd/.conda/envs/obj013-env-vllm/lib/python3.10/multiprocessing/resource_tracker.py", line 209, in main cache[rtype].remove(name) KeyError: '/psm_15339bca' Traceback (most recent call last): File "/home/aabbccddwasd/.conda/envs/obj013-env-vllm/lib/python3.10/multiprocessing/resource_tracker.py", line 209, in main cache[rtype].remove(name) KeyError: '/psm_15339bca' WARNING 06-30 18:37:20 custom_all_reduce.py:166] Custom allreduce is disabled because it's not supported on more than two PCIe-only GPUs. To silence this warning, specify disable_custom_all_reduce=True explicitly. (VllmWorkerProcess pid=332366) WARNING 06-30 18:37:20 custom_all_reduce.py:166] Custom allreduce is disabled because it's not supported on more than two PCIe-only GPUs. To silence this warning, specify disable_custom_all_reduce=True explicitly. (VllmWorkerProcess pid=332365) WARNING 06-30 18:37:20 custom_all_reduce.py:166] Custom allreduce is disabled because it's not supported on more than two PCIe-only GPUs. To silence this warning, specify disable_custom_all_reduce=True explicitly. (VllmWorkerProcess pid=332367) WARNING 06-30 18:37:20 custom_all_reduce.py:166] Custom allreduce is disabled because it's not supported on more than two PCIe-only GPUs. To silence this warning, specify disable_custom_all_reduce=True explicitly. INFO 06-30 18:37:20 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. INFO 06-30 18:37:20 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332366) INFO 06-30 18:37:20 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332366) INFO 06-30 18:37:20 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332367) INFO 06-30 18:37:20 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332367) INFO 06-30 18:37:20 selector.py:51] Using XFormers backend. (VllmWorkerProcess pid=332365) INFO 06-30 18:37:20 selector.py:131] Cannot use FlashAttention-2 backend for Volta and Turing GPUs. (VllmWorkerProcess pid=332365) INFO 06-30 18:37:20 selector.py:51] Using XFormers backend. INFO 06-30 18:37:30 model_runner.py:160] Loading model weights took 17.9828 GB (VllmWorkerProcess pid=332367) INFO 06-30 18:37:30 model_runner.py:160] Loading model weights took 17.9828 GB (VllmWorkerProcess pid=332365) INFO 06-30 18:37:30 model_runner.py:160] Loading model weights took 17.9828 GB (VllmWorkerProcess pid=332366) INFO 06-30 18:37:30 model_runner.py:160] Loading model weights took 17.9828 GB

before loading weight it already consumed 18.7G VRAM ↓ image

Please help me with this problem, thanks,,,

w013nad commented 2 weeks ago

Vllm has to have available memory for the entire KV cache which for Qwen 2 is 32k. Try setting max-model-len to lower. Also, set gpu_memory_utilization to 0.98. The value is the percentage of total GPU memory it's allowed to use. It needs 18 GB/GPU for the model alone, it looks like it's seeing that it's using more than 2GB and throws an error.

aabbccddwasd commented 2 weeks ago

OK,looks like max-model-len is working, but how can I do this with LLM(), it doesn't have a parameter called "max_model_len" and "max_seq_len_to_capture" don't work

robertgshaw2-neuralmagic commented 2 weeks ago

You should be able to set max_model_len for LLM

aabbccddwasd commented 2 weeks ago

You should be able to set max_model_len for LLM

OK I succeeded, I know the problem:max_model_len in **kwargs is not shown in pycharm image

aabbccddwasd commented 2 weeks ago

I also noticed a problem, when I use python -m vllm.entrypoints.openai.api_server, I can set max_model_len to 8700, but the maximum max_model_len I can set in LLM() is 8200, the other parameters is same this is my code

llm = LLM(model="../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8",
              tensor_parallel_size=4,
              gpu_memory_utilization=1,
              enforce_eager=True,
              max_model_len=8200)

the command

python -m vllm.entrypoints.openai.api_server --model ./Qwen2-72B-Instruct-GPTQ-Int8 --tensor-parallel-size=4 --gpu-memory-utilization 1 --max-model-len 8700 --enforce-eager