vllm-project / vllm

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

[Bug]: with_pynccl_for_all_reduce causes GPU OOM #4472

Closed sfc-gh-zhwang closed 6 months ago

sfc-gh-zhwang commented 6 months ago

Your current environment

PyTorch version: 2.2.1+cu121
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 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: Could not collect
CMake version: version 3.28.3
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-5.10.213-201.855.amzn2.x86_64-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.4.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A100-SXM4-40GB
GPU 1: NVIDIA A100-SXM4-40GB
GPU 2: NVIDIA A100-SXM4-40GB
GPU 3: NVIDIA A100-SXM4-40GB
GPU 4: NVIDIA A100-SXM4-40GB
GPU 5: NVIDIA A100-SXM4-40GB
GPU 6: NVIDIA A100-SXM4-40GB
GPU 7: NVIDIA A100-SXM4-40GB

Nvidia driver version: 535.161.08
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_adv.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_cnn.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_precompiled.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_graph.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_heuristic.so.9.0.0
/usr/lib/x86_64-linux-gnu/libcudnn_ops.so.9.0.0
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):                             96
On-line CPU(s) list:                0-95
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Xeon(R) Platinum 8275CL CPU @ 3.00GHz
CPU family:                         6
Model:                              85
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          2
Stepping:                           7
BogoMIPS:                           5999.99
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 nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves ida arat pku ospke
Hypervisor vendor:                  KVM
Virtualization type:                full
L1d cache:                          1.5 MiB (48 instances)
L1i cache:                          1.5 MiB (48 instances)
L2 cache:                           48 MiB (48 instances)
L3 cache:                           71.5 MiB (2 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-23,48-71
NUMA node1 CPU(s):                  24-47,72-95
Vulnerability Gather data sampling: Unknown: Dependent on hypervisor status
Vulnerability Itlb multihit:        KVM: Mitigation: VMX unsupported
Vulnerability L1tf:                 Mitigation; PTE Inversion
Vulnerability Mds:                  Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Meltdown:             Mitigation; PTI
Vulnerability Mmio stale data:      Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown
Vulnerability Retbleed:             Vulnerable
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Vulnerable
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, STIBP disabled, RSB filling
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.4
[pip3] nvidia-nccl-cu12==2.19.3
[pip3] onnx==1.15.0rc2
[pip3] optree==0.10.0
[pip3] pytorch-quantization==2.1.2
[pip3] pytorch-triton==2.2.0+e28a256d7
[pip3] torch==2.2.1
[pip3] torch-tensorrt==2.3.0a0
[pip3] torchdata==0.7.1a0
[pip3] torchtext==0.17.0a0
[pip3] torchvision==0.18.0a0
[pip3] triton==2.2.0
[pip3] vllm-nccl-cu12==2.18.1.0.4.0
[conda] Could not collectROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.0.post1
vLLM Build Flags:
CUDA Archs: 5.2 6.0 6.1 7.0 7.2 7.5 8.0 8.6 8.7 9.0+PTX; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  NV12    NV12    NV12    NV12    NV12    NV12    NV12    0-23,48-71  0       N/A
GPU1    NV12     X  NV12    NV12    NV12    NV12    NV12    NV12    0-23,48-71  0       N/A
GPU2    NV12    NV12     X  NV12    NV12    NV12    NV12    NV12    0-23,48-71  0       N/A
GPU3    NV12    NV12    NV12     X  NV12    NV12    NV12    NV12    0-23,48-71  0       N/A
GPU4    NV12    NV12    NV12    NV12     X  NV12    NV12    NV12    24-47,72-95 1       N/A
GPU5    NV12    NV12    NV12    NV12    NV12     X  NV12    NV12    24-47,72-95 1       N/A
GPU6    NV12    NV12    NV12    NV12    NV12    NV12     X  NV12    24-47,72-95 1       N/A
GPU7    NV12    NV12    NV12    NV12    NV12    NV12    NV12     X  24-47,72-95 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 am running llama2-70b-chat mode on a 40GiBx8 A100 node.

from vllm import LLM, SamplingParams

prompts = [
    "Hello, my name is",
]

sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

llm = LLM(
    model="/models/llama2-70b-chat",
    tensor_parallel_size=8,
    gpu_memory_utilization=0.85,
    disable_custom_all_reduce=True,
)

outputs = llm.generate(prompts, sampling_params)

# Print the outputs.
for output in outputs:
    prompt = output.prompt
    generated_text = output.outputs[0].text
    print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")

Error is linked here: https://gist.github.com/sfc-gh-zhwang/5e4cd04d87a1823a316d983289dfbd21

youkaichao commented 6 months ago

How do you install vllm? What is the command you run? As which user?

The message you post in slack channel is:

vLLM is using nccl==2.20.5

However, normally this should be 2.18.1 , since :

[pip3] vllm-nccl-cu12==2.18.1.0.4.0

Besides, please post full logging information to help identify the problem.

sfc-gh-zhwang commented 6 months ago

Sorry, i have two environments, and the log is a bit messed up, now updated with a fixed version and full log+error message is uploaded through a gist.

We installed vllm through docker, but before that we installed aws's own nccl plugin, i guess this might cause issue?

FROM nvcr.io/nvidia/pytorch:24.03-py3

USER root

RUN apt-get update -y
RUN apt-get install -y --no-install-recommends \
    git \
    git-lfs \
    htop \
    libaio-dev \
    libhwloc-dev

RUN git lfs install

# Install EFA
RUN curl -O https://efa-installer.amazonaws.com/aws-efa-installer-1.29.0.tar.gz
RUN tar -xf aws-efa-installer-1.29.0.tar.gz && \
    cd aws-efa-installer && \
    ./efa_installer.sh -y -g -d --skip-kmod --skip-limit-conf --no-verify

# Install custom aws-ofi-nccl plugin in order to avoid GPU memory fragmentation
RUN wget https://github.com/aws/aws-ofi-nccl/releases/download/v1.7.4-aws/aws-ofi-nccl-1.7.4-aws.tar.gz
RUN tar -xf aws-ofi-nccl-1.7.4-aws.tar.gz && \
    cd aws-ofi-nccl-1.7.4-aws && \
    ./configure --prefix=/opt/aws-ofi-nccl \
    --with-mpi=/opt/amazon/openmpi \
    --with-libfabric=/opt/amazon/efa \
    --with-cuda=/usr/local/cuda \
    --enable-platform-aws && \
    make && make install

ENV LD_LIBRARY_PATH="/opt/aws-ofi-nccl/lib:$LD_LIBRARY_PATH"
ENV PATH="/opt/aws-ofi-nccl/bin:/opt/amazon/efa:/opt/amazon/openmpi/bin/:$PATH"

RUN addgroup corvo -gid 1000
RUN adduser -disabled-password -u 1000 -gid 1000 corvo

USER corvo
WORKDIR /home/corvo

ENV VLLM_INSTALL_PUNICA_KERNELS=1

RUN pip install -e vllm
youkaichao commented 6 months ago

It is a known issue for nccl >= 2.19 to have memory issue when used with cudagraph: https://github.com/NVIDIA/nccl/issues/1234

If you are using multiple users in docker, be sure to check out the doc https://docs.vllm.ai/en/latest/serving/deploying_with_docker.html :

vLLM docker image is currently designed to be run under the root user (contribution welcomed for changing this!). It will try to load library at runtime under the root user’s home directory, e.g. /root/.config/vllm/nccl/cu12/libnccl.so.2.18.1 . If you are running the container under a different user, you may need to change the permissions of the library (and all the parent directories) to allow the user to access it. Then run vLLM with environment variable VLLM_NCCL_SO_PATH=/root/.config/vllm/nccl/cu12/libnccl.so.2.18.1 .

sfc-gh-zhwang commented 6 months ago

@youkaichao THANKS A LOT for the information, I took a look at our config and combine your information, i think i know what happened. We somehow mount a dir at /root/.config/vllm so the original nccl so was removed.