vllm-project / vllm

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

[Usage]: cannot load llama 3.2 3b on a 16gb gpu when gpu_memory_utilisation=1 #10797

Open TheKidThatCodes opened 2 days ago

TheKidThatCodes commented 2 days ago

Your current environment

Collecting environment information...
PyTorch version: 2.5.1+cu124
Is debug build: False
CUDA used to build PyTorch: 12.4
ROCM used to build PyTorch: N/A

OS: Ubuntu 24.10 (x86_64)
GCC version: (Ubuntu 14.2.0-4ubuntu2) 14.2.0
Clang version: 19.1.1 (1ubuntu1)
CMake version: version 3.30.3
Libc version: glibc-2.40

Python version: 3.12.7 (main, Nov  6 2024, 18:29:01) [GCC 14.2.0] (64-bit runtime)
Python platform: Linux-6.11.0-9-generic-x86_64-with-glibc2.40
Is CUDA available: True
CUDA runtime version: 12.6.77
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4080
Nvidia driver version: 565.57.01
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:                        48 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               32
On-line CPU(s) list:                  0-31
Vendor ID:                            AuthenticAMD
Model name:                           AMD Ryzen 9 7950X 16-Core Processor
CPU family:                           25
Model:                                97
Thread(s) per core:                   2
Core(s) per socket:                   16
Socket(s):                            1
Stepping:                             2
Frequency boost:                      enabled
CPU(s) scaling MHz:                   67%
CPU max MHz:                          5881.0000
CPU min MHz:                          545.0000
BogoMIPS:                             8983.23
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 v_vmsave_vmload 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:                            512 KiB (16 instances)
L1i cache:                            512 KiB (16 instances)
L2 cache:                             16 MiB (16 instances)
L3 cache:                             64 MiB (2 instances)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-31
Vulnerability Gather data sampling:   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; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.4.5.8
[pip3] nvidia-cuda-cupti-cu12==12.4.127
[pip3] nvidia-cuda-nvrtc-cu12==12.4.127
[pip3] nvidia-cuda-runtime-cu12==12.4.127
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.2.1.3
[pip3] nvidia-curand-cu12==10.3.5.147
[pip3] nvidia-cusolver-cu12==11.6.1.9
[pip3] nvidia-cusparse-cu12==12.3.1.170
[pip3] nvidia-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.21.5
[pip3] nvidia-nvjitlink-cu12==12.4.127
[pip3] nvidia-nvtx-cu12==12.4.127
[pip3] pyzmq==26.2.0
[pip3] torch==2.5.1
[pip3] torchvision==0.20.1
[pip3] transformers==4.46.3
[pip3] triton==3.1.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.4.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  0-31    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

LD_LIBRARY_PATH=/home/~/vllm/.venv/lib/python3.12/site-packages/cv2/../../lib64:/usr/local/cuda-12.6/lib64:/usr/local/cuda-12.6/lib64:
CUDA_MODULE_LOADING=LAZY

How would you like to use vllm

I want to run inference of a [llama 3.2 3b](put link here). it keeps saying i dont have enough memory

INFO 11-30 13:57:06 model_runner.py:1077] Loading model weights took 3.2636 GB
INFO 11-30 13:57:06 worker.py:232] Memory profiling results: total_gpu_memory=15.56GiB initial_memory_usage=4.78GiB peak_torch_memory=4.43GiB memory_usage_post_profile=4.78GiB non_torch_memory=1.52GiB kv_cache_size=9.62GiB gpu_memory_utilization=1.00
INFO 11-30 13:57:07 gpu_executor.py:113] # GPU blocks: 5626, # CPU blocks: 2340
INFO 11-30 13:57:07 gpu_executor.py:117] Maximum concurrency for 131072 tokens per request: 0.69x
ERROR 11-30 13:57:07 engine.py:366] The model's max seq len (131072) is larger than the maximum number of tokens that can be stored in KV cache (90016). Try increasing `gpu_memory_utilization` or decreasing `max_model_len` when initializing the engine.

Before submitting a new issue...

TheKidThatCodes commented 2 days ago

to clarify, i would prefer to use vllm instead of llama.cpp python whatever its called, because vllm has incredible performance when it works

DarkLight1337 commented 1 day ago

You should avoid setting gpu_memory_utilization=1 since some of the GPU is reserved even when idle. To reduce memory cost of vLLM, you can choose a smaller value of max_model_len and/or max_num_seqs.

TheKidThatCodes commented 1 day ago

You should avoid setting gpu_memory_utilization=1 since some of the GPU is reserved even when idle. To reduce memory cost of vLLM, you can choose a smaller value of max_model_len and/or max_num_seqs.

what would you recommend to set it to

DarkLight1337 commented 1 day ago

Please check out https://github.com/vllm-project/vllm/blob/main/examples%2Foffline_inference_vision_language.py

jikunshang commented 20 hours ago

BTW, you can also set --max-model-len to reduce memory usage if you don't need full context. it will use model's max output len if you didn't specify. in llama 3.2 case, it's 128K. it cause this error ERROR 11-30 13:57:07 engine.py:366] The model's max seq len (131072) is larger than the maximum number of tokens that can be stored in KV cache (90016). Try increasinggpu_memory_utilizationor decreasingmax_model_lenwhen initializing the engine.