vllm-project / vllm

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

[Usage]: cannot load GGUF model on multi GPU #10204

Closed kbfifi closed 3 weeks ago

kbfifi commented 3 weeks ago

Your current environment

The output of `python collect_env.py`
WARNING 11-10 22:34:11 cuda.py:76] Detected different devices in the system: 
WARNING 11-10 22:34:11 cuda.py:76] NVIDIA GeForce RTX 3090
WARNING 11-10 22:34:11 cuda.py:76] NVIDIA GeForce RTX 3080
WARNING 11-10 22:34:11 cuda.py:76] Please make sure to set `CUDA_DEVICE_ORDER=PCI_BUS_ID` to avoid unexpected behavior.
Collecting environment information...
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: Ubuntu 22.04.3 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.10.15 (main, Oct  3 2024, 07:27:34) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
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 3080

Nvidia driver version: 560.94
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:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             16
On-line CPU(s) list:                0-15
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
CPU family:                         6
Model:                              158
Thread(s) per core:                 2
Core(s) per socket:                 8
Socket(s):                          1
Stepping:                           13
BogoMIPS:                           7200.02
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid pni pclmulqdq vmx ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          256 KiB (8 instances)
L1i cache:                          256 KiB (8 instances)
L2 cache:                           2 MiB (8 instances)
L3 cache:                           16 MiB (1 instance)
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Unknown: Dependent on hypervisor status
Vulnerability Tsx async abort:      Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-cublas-cu12==12.1.3.1
[pip3] nvidia-cuda-cupti-cu12==12.1.105
[pip3] nvidia-cuda-nvrtc-cu12==12.1.105
[pip3] nvidia-cuda-runtime-cu12==12.1.105
[pip3] nvidia-cudnn-cu12==9.1.0.70
[pip3] nvidia-cufft-cu12==11.0.2.54
[pip3] nvidia-curand-cu12==10.3.2.106
[pip3] nvidia-cusolver-cu12==11.4.5.107
[pip3] nvidia-cusparse-cu12==12.1.0.106
[pip3] nvidia-ml-py==12.560.30
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] nvidia-nvjitlink-cu12==12.6.77
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] pyzmq==26.2.0
[pip3] torch==2.4.0
[pip3] torchvision==0.19.0
[pip3] transformers==4.46.2
[pip3] triton==3.0.0
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] nvidia-cublas-cu12        12.1.3.1                 pypi_0    pypi
[conda] nvidia-cuda-cupti-cu12    12.1.105                 pypi_0    pypi
[conda] nvidia-cuda-nvrtc-cu12    12.1.105                 pypi_0    pypi
[conda] nvidia-cuda-runtime-cu12  12.1.105                 pypi_0    pypi
[conda] nvidia-cudnn-cu12         9.1.0.70                 pypi_0    pypi
[conda] nvidia-cufft-cu12         11.0.2.54                pypi_0    pypi
[conda] nvidia-curand-cu12        10.3.2.106               pypi_0    pypi
[conda] nvidia-cusolver-cu12      11.4.5.107               pypi_0    pypi
[conda] nvidia-cusparse-cu12      12.1.0.106               pypi_0    pypi
[conda] nvidia-ml-py              12.560.30                pypi_0    pypi
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] nvidia-nvjitlink-cu12     12.6.77                  pypi_0    pypi
[conda] nvidia-nvtx-cu12          12.1.105                 pypi_0    pypi
[conda] pyzmq                     26.2.0                   pypi_0    pypi
[conda] torch                     2.4.0                    pypi_0    pypi
[conda] torchvision               0.19.0                   pypi_0    pypi
[conda] transformers              4.46.2                   pypi_0    pypi
[conda] triton                    3.0.0                    pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.6.3.post1
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  SYS             N/A
GPU1    SYS  X              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/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/cv2/../../lib64:
CUDA_MODULE_LOADING=LAZY

How would you like to use vllm

I want this script to work so that I can use it for local inference. The llama31 model works for the 2 GPUs (3080, 3090) using llama.cpp so I expect it to fit in the total available VRAM (34GB) in my system. Now I get OOM errors. I tried to minimize the usage but no success.

I managed to get VLLM working using: model=bigcode/starcoder2-7b template=./templates/starcode.jinja (selfmade) (btw: where can I find a proper template for starcode?)

I hope someone can help me out to get de llama31 model running

!/bin/bash

source activate vllm export CUDA_DEVICE_ORDER=PCI_BUS_ID export NVIDIA_VISIBLE_DEVICES=0,1 # Make both GPUs visible

max_tokens=1024 template=./templates/llama31.jinja model=/mnt/extra_ext4/models/Llama-3.1-Nemotron-70B-Instruct-HF-IQ3_M.gguf

vllm serve $model \ --enable_chunked_prefill True \ --chat-template "$template" \ --tensor-parallel-size 2 \ --max-num-batched-tokens $max_tokens \ --gpu-memory-utilization 0.7 \ --max-num-seqs=1 \ --block-size 16 source deactivate


This reults in the following log:

INFO 11-10 22:42:32 api_server.py:529] args: Namespace(subparser='serve', model_tag='/mnt/extra_ext4/models/Llama-3.1-Nemotron-70B-Instruct-HF-IQ3_M.gguf', config='', host=None, port=8000, uvicorn_log_level='info', allow_credentials=False, allowed_origins=['*'], allowed_methods=['*'], allowed_headers=['*'], api_key=None, lora_modules=None, prompt_adapters=None, chat_template='./templates/llama31.jinja', response_role='assistant', ssl_keyfile=None, ssl_certfile=None, ssl_ca_certs=None, ssl_cert_reqs=0, root_path=None, middleware=[], return_tokens_as_token_ids=False, disable_frontend_multiprocessing=False, enable_auto_tool_choice=False, tool_call_parser=None, tool_parser_plugin='', model='/mnt/extra_ext4/models/Llama-3.1-Nemotron-70B-Instruct-HF-IQ3_M.gguf', tokenizer=None, skip_tokenizer_init=False, revision=None, code_revision=None, tokenizer_revision=None, tokenizer_mode='auto', trust_remote_code=False, download_dir=None, load_format='auto', config_format=<ConfigFormat.AUTO: 'auto'>, dtype='auto', kv_cache_dtype='auto', quantization_param_path=None, max_model_len=None, guided_decoding_backend='outlines', distributed_executor_backend=None, worker_use_ray=False, pipeline_parallel_size=1, tensor_parallel_size=2, max_parallel_loading_workers=None, ray_workers_use_nsight=False, block_size=16, enable_prefix_caching=False, disable_sliding_window=False, use_v2_block_manager=False, num_lookahead_slots=0, seed=0, swap_space=4, cpu_offload_gb=0, gpu_memory_utilization=0.7, num_gpu_blocks_override=None, max_num_batched_tokens=1024, max_num_seqs=1, max_logprobs=20, disable_log_stats=False, quantization=None, rope_scaling=None, rope_theta=None, enforce_eager=False, max_context_len_to_capture=None, max_seq_len_to_capture=8192, disable_custom_all_reduce=False, tokenizer_pool_size=0, tokenizer_pool_type='ray', tokenizer_pool_extra_config=None, limit_mm_per_prompt=None, mm_processor_kwargs=None, enable_lora=False, max_loras=1, max_lora_rank=16, lora_extra_vocab_size=256, lora_dtype='auto', long_lora_scaling_factors=None, max_cpu_loras=None, fully_sharded_loras=False, enable_prompt_adapter=False, max_prompt_adapters=1, max_prompt_adapter_token=0, device='auto', num_scheduler_steps=1, multi_step_stream_outputs=True, scheduler_delay_factor=0.0, enable_chunked_prefill=True, speculative_model=None, speculative_model_quantization=None, num_speculative_tokens=None, speculative_disable_mqa_scorer=False, speculative_draft_tensor_parallel_size=None, speculative_max_model_len=None, speculative_disable_by_batch_size=None, ngram_prompt_lookup_max=None, ngram_prompt_lookup_min=None, spec_decoding_acceptance_method='rejection_sampler', typical_acceptance_sampler_posterior_threshold=None, typical_acceptance_sampler_posterior_alpha=None, disable_logprobs_during_spec_decoding=None, model_loader_extra_config=None, ignore_patterns=[], preemption_mode=None, served_model_name=None, qlora_adapter_name_or_path=None, otlp_traces_endpoint=None, collect_detailed_traces=None, disable_async_output_proc=False, override_neuron_config=None, scheduling_policy='fcfs', disable_log_requests=False, max_log_len=None, disable_fastapi_docs=False, dispatch_function=<function serve at 0x7f97166b7d90>)

Ends with:

(VllmWorkerProcess pid=235206) INFO 11-10 22:43:39 model_runner.py:1056] Starting to load model /mnt/extra_ext4/models/Llama-3.1-Nemotron-70B-Instruct-HF-IQ3_M.gguf...
/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/torch/nested/__init__.py:220: UserWarning: The PyTorch API of nested tensors is in prototype stage and will change in the near future. (Triggered internally at ../aten/src/ATen/NestedTensorImpl.cpp:178.)
  return _nested.nested_tensor(
(VllmWorkerProcess pid=235206) /home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/torch/nested/__init__.py:220: UserWarning: The PyTorch API of nested tensors is in prototype stage and will change in the near future. (Triggered internally at ../aten/src/ATen/NestedTensorImpl.cpp:178.)
(VllmWorkerProcess pid=235206)   return _nested.nested_tensor(
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229] Exception in worker VllmWorkerProcess while processing method load_model.
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229] Traceback (most recent call last):
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/executor/multiproc_worker_utils.py", line 223, in _run_worker_process
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     output = executor(*args, **kwargs)
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/worker/worker.py", line 183, in load_model
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     self.model_runner.load_model()
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/worker/model_runner.py", line 1058, in load_model
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     self.model = get_model(model_config=self.model_config,
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/model_loader/__init__.py", line 19, in get_model
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     return loader.load_model(model_config=model_config,
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/model_loader/loader.py", line 1233, in load_model
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     model.load_weights(
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/models/llama.py", line 582, in load_weights
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     loader.load_weights(
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/models/utils.py", line 203, in load_weights
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     autoloaded_weights = list(self._load_module("", self.module, weights))
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/models/utils.py", line 182, in _load_module
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     yield from self._load_module(prefix,
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/models/utils.py", line 169, in _load_module
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     module_load_weights(weights)
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/models/llama.py", line 399, in load_weights
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     weight_loader(param, loaded_weight, shard_id)
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/layers/linear.py", line 799, in weight_loader
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     self.qweight = param.materialize_nested()
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/vllm/model_executor/layers/quantization/gguf.py", line 169, in materialize_nested
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     nested_data = torch.nested.nested_tensor(self.data_container,
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]   File "/home/kurt/miniconda3/envs/vllm/lib/python3.10/site-packages/torch/nested/__init__.py", line 220, in nested_tensor
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229]     return _nested.nested_tensor(
(VllmWorkerProcess pid=235206) ERROR 11-10 22:44:26 multiproc_worker_utils.py:229] torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB. GPU 1 has a total capacity of 10.00 GiB of which 0 bytes is free. Process 235098 has 17179869184.00 GiB memory in use. Including non-PyTorch memory, this process has 17179869184.00 GiB memory in use. Of the allocated memory 9.04 GiB is allocated by PyTorch, and 273.48 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation.  See documentation for Memory Management  (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
INFO 11-10 22:44:44 model_runner.py:1067] Loading model weights took 14.9101 GB

Before submitting a new issue...

Isotr0py commented 3 weeks ago

3080 and 3090 have different VRAM, so using tensor parallel will cause OOM on 3080 due to unbalanced VRAM. You can try using pipeline parallel with --pipeline-parallel-size=2.

kbfifi commented 3 weeks ago

@Isotr0py thanks for pointing out unbalance! I searched and saw indeed that llama.cpp can apparently VLLM can't deal with this. As my goal was to maximize inferenceperformance with this HW setup I think VLLM is not an improvement over llama.cpp with this HW.