vllm [Bug]: 加载Qwen2 GPT时出现OOM,修改gpu_memory_utilization无法解决问题,

h9a6wy2h  于 6个月前  发布在  其他
关注(0)|答案(5)|浏览(71)

当前环境

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

🐛 描述问题

我将gpu_memory_utilization设置为0.1,但在加载权重之前,vllm已经消耗了18.7G VRAM,接近22GB * 0.9 = 19.8G。当权重被加载时,22GB的2080ti出现了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)

我将gpu_memory_utilization设置为0.1,但在加载权重之前,vllm已经消耗了18.7G VRAM,接近22GB * 0.9 = 19.8G。当权重被加载时,22GB的2080ti出现了OOM错误。我还尝试了python -m vllm.entrypoints.openai.api_server --model ../obj013-qwen/Qwen2-72B-Instruct-GPTQ-Int8 --tensor-parallel-size=4 --gpu-memory-utilization 0.1,但效果并不理想。
也许这与gpu_memory_utilization无关,但当我加载AWQ模型并修改gpu_memory_utilization时,实际消耗的VRAM并没有改变。所以我猜测问题是由gpu_memory_utilization引起的。首先它输出了这个信息,然后所有的输出都是OOM错误。
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
在加载权重之前已经消耗了18.7G VRAM↓

请帮助我解决这个问题,谢谢!

nvbavucw

nvbavucw1#

Vllm必须为整个KV缓存提供可用内存,对于Qwen 2来说是32k。尝试将max-model-len设置得更低。此外,将gpu_memory_utilization设置为0.98。这个值是允许使用的GPU内存的百分比。仅模型就需要每个GPU18GB,看起来它正在使用超过2GB并且抛出错误。

cngwdvgl

cngwdvgl2#

好的,看起来max-model-len是起作用的,但是我该如何在LLM()中实现这个功能呢?它没有一个叫做"max_model_len"的参数,而且"max_seq_len_to_capture"也不起作用。

w51jfk4q

w51jfk4q3#

你应该能够为LLM设置max_model_len

ac1kyiln

ac1kyiln4#

你应该能够为LLM设置max_model_len
OK,我成功了
我知道问题:在PyCharm中**kwargs中的max_model_len没有显示出来

f4t66c6m

f4t66c6m5#

我也注意到了一个问题,当我使用python -m vllm.entrypoints.openai.api_server时,我可以将max_model_len设置为8700,但是在LLM()中我最多可以设置的max_model_len是8200,其他参数都是一样的。这是我的代码:

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)

这是命令:

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

相关问题