QwenLM / Qwen2-VL

Qwen2-VL is the multimodal large language model series developed by Qwen team, Alibaba Cloud.
Apache License 2.0
3.23k stars 202 forks source link

GPU Memory Exception(显存异常) #186

Open Muttermal opened 2 months ago

Muttermal commented 2 months ago

Hi, I encountered an abnormal memory usage issue when deploying Qwen2-VL-7B-Instruct using vllm. My specific configuration is as follows: (Hi,我使用vllm部署Qwen2-VL-7B-Instruct遇到了显存占用异常的问题。我的具体配置如下)

Env(环境)

PyTorch version: 2.4.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: CentOS Stream 8 (x86_64)
GCC version: (GCC) 8.5.0 20210514 (Red Hat 8.5.0-21)
Clang version: Could not collect
CMake version: version 3.29.0
Libc version: glibc-2.28

Python version: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-4.18.0-193.el8.x86_64-x86_64-with-glibc2.28
Is CUDA available: True
CUDA runtime version: 12.2.140
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A40
GPU 1: NVIDIA A40
GPU 2: NVIDIA A40
GPU 3: NVIDIA A40
GPU 4: NVIDIA A40
GPU 5: NVIDIA A40
GPU 6: NVIDIA A40
GPU 7: NVIDIA A40

Nvidia driver version: 535.154.05
cuDNN version: Probably one of the following:
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_adv_train.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8
/usr/local/cuda-11.2/targets/x86_64-linux/lib/libcudnn_ops_train.so.8
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
Byte Order:          Little Endian
CPU(s):              112
On-line CPU(s) list: 0-111
Thread(s) per core:  2
Core(s) per socket:  28
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               106
Model name:          Intel(R) Xeon(R) Gold 6348 CPU @ 2.60GHz
Stepping:            6
CPU MHz:             3400.000
CPU max MHz:         2601.0000
CPU min MHz:         800.0000
BogoMIPS:            5200.00
Virtualization:      VT-x
L1d cache:           48K
L1i cache:           32K
L2 cache:            1280K
L3 cache:            43008K
NUMA node0 CPU(s):   0-27,56-83
NUMA node1 CPU(s):   28-55,84-111
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 art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 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 invpcid_single ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid md_clear pconfig flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] open-clip-torch==2.24.0
[pip3] pyzmq==25.1.2
[pip3] sentence-transformers==2.7.0
[pip3] torch==2.4.0
[pip3] torchvision==0.19.0
[pip3] transformers==4.45.0.dev0
[pip3] transformers-stream-generator==0.0.5
[pip3] triton==3.0.0
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] open-clip-torch           2.24.0                   pypi_0    pypi
[conda] pyzmq                     25.1.2                   pypi_0    pypi
[conda] sentence-transformers     2.7.0                    pypi_0    pypi
[conda] torch                     2.4.0                    pypi_0    pypi
[conda] torchvision               0.19.0                   pypi_0    pypi
[conda] transformers              4.45.0.dev0              pypi_0    pypi
[conda] transformers-stream-generator 0.0.5                    pypi_0    pypi
[conda] triton                    3.0.0                    pypi_0    pypi
[conda] vllm-nccl-cu12            2.18.1.0.4.0             pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.1@3fd2b0d21cd9ec78de410fdf8aa1de840e9ad77a
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      PIX     PIX     PIX     SYS     SYS     SYS     SYS     0-27,56-83      0               N/A
GPU1    PIX      X      PIX     PIX     SYS     SYS     SYS     SYS     0-27,56-83      0               N/A
GPU2    PIX     PIX      X      PIX     SYS     SYS     SYS     SYS     0-27,56-83      0               N/A
GPU3    PIX     PIX     PIX      X      SYS     SYS     SYS     SYS     0-27,56-83      0               N/A
GPU4    SYS     SYS     SYS     SYS      X      PIX     PIX     PIX     28-55,84-111    1               N/A
GPU5    SYS     SYS     SYS     SYS     PIX      X      PIX     PIX     28-55,84-111    1               N/A
GPU6    SYS     SYS     SYS     SYS     PIX     PIX      X      PIX     28-55,84-111    1               N/A
GPU7    SYS     SYS     SYS     SYS     PIX     PIX     PIX      X      28-55,84-111    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

The installation method for transformers is (其中transformers的安装方式为)

pip install git+https://github.com/huggingface/transformers@21fac7abba2a37fae86106f87fcf9974fd1e3830 accelerate

Script(启动脚本)

export CUDA_VISIBLE_DEVICES=4,5,6,7
export VLLM_WORKER_MULTIPROC_METHOD=spawn
export MAX_PIXELS=100000

model_path=/mnt/pretrained_models/Qwen2-VL-7B-Instruct
host=0.0.0.0
port=8001

python -m vllm.entrypoints.openai.api_server \
   --device cuda \
   --model $model_path \
   --dtype auto \
   --host $host \
   --port $port \
   --tensor-parallel-size 4 \
   --served-model-name qwenvl2 \
   --max-model-len 16384

GPU memory usage(显存占用)

qwenvl

Question(问题)

The service starts normally, but without any inference, the 7B model almost fully occupies the memory of four 48GB GPUs. Could you help me check where the issue might be?(服务启动正常,但在没有任何推理的情况下,7B的模型几乎占满了四张48G显存的显卡,请问可以帮我看看具体是哪里出了问题吗?)

jklj077 commented 2 months ago

Hi, for vLLM, this is expected since it preallocates GPU memory as the "--gpu-memory-utilization" parameter which defaults to 0.9. For more information, please refer to the vLLM documentation.

RANYABING commented 1 month ago

您好,请问您解决这个问题了吗?我用4卡A800推理72B,也遇到了OOM。