vllm: [Bug]: PaliGemma serving

Your current environment

Collecting environment information...
PyTorch version: 2.3.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.22.1
Libc version: glibc-2.35

Python version: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.1.0-21-amd64-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 12.1.105
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A800 80GB PCIe
Nvidia driver version: 525.147.05
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:                        43 bits physical, 48 bits virtual
Byte Order:                           Little Endian
CPU(s):                               24
On-line CPU(s) list:                  0-23
Vendor ID:                            AuthenticAMD
Model name:                           AMD EPYC 7352 24-Core Processor
CPU family:                           23
Model:                                49
Thread(s) per core:                   1
Core(s) per socket:                   24
Socket(s):                            1
Stepping:                             0
Frequency boost:                      enabled
CPU max MHz:                          2300.0000
CPU min MHz:                          1500.0000
BogoMIPS:                             4600.10
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 nopl 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 ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sev sev_es
Virtualization:                       AMD-V
L1d cache:                            768 KiB (24 instances)
L1i cache:                            768 KiB (24 instances)
L2 cache:                             12 MiB (24 instances)
L3 cache:                             128 MiB (8 instances)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-23
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:               Mitigation; untrained return thunk; SMT disabled
Vulnerability Spec rstack overflow:   Mitigation; SMT disabled
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; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Not affected
Vulnerability Tsx async abort:        Not affected

Versions of relevant libraries:
[pip3] lion-pytorch==0.1.4
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] onnx==1.16.0
[pip3] onnx-graphsurgeon==0.5.2
[pip3] onnxruntime==1.16.3
[pip3] onnxruntime-gpu==1.17.1
[pip3] open-clip-torch==2.24.0
[pip3] pytorch-lightning==2.2.4
[pip3] torch==2.3.1
[pip3] torchaudio==2.3.1
[pip3] torchdata==0.7.1
[pip3] torchmetrics==1.3.2
[pip3] torchvision==0.18.1
[pip3] transformers==4.42.4
[pip3] triton==2.3.1
[pip3] tritonclient==2.45.0
[conda] lion-pytorch              0.1.4                    pypi_0    pypi
[conda] numpy                     1.26.4          py311h24aa872_0  
[conda] numpy-base                1.26.4          py311hbfb1bba_0  
[conda] nvidia-nccl-cu12          2.20.5                   pypi_0    pypi
[conda] open-clip-torch           2.24.0                   pypi_0    pypi
[conda] pytorch-lightning         2.2.4                    pypi_0    pypi
[conda] torch                     2.3.1                    pypi_0    pypi
[conda] torchaudio                2.3.1                    pypi_0    pypi
[conda] torchdata                 0.7.1                    pypi_0    pypi
[conda] torchmetrics              1.3.2                    pypi_0    pypi
[conda] torchvision               0.18.1                   pypi_0    pypi
[conda] transformers              4.42.4                   pypi_0    pypi
[conda] triton                    2.3.1                    pypi_0    pypi
[conda] tritonclient              2.45.0                   pypi_0    pypi
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.2
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    NIC0    NIC1    CPU Affinity    NUMA Affinity
GPU0     X      SYS     SYS     0-23            N/A
NIC0    SYS      X      PIX
NIC1    SYS     PIX      X 

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

NIC Legend:

  NIC0: mlx5_0
  NIC1: mlx5_1

🐛 Describe the bug

I run the following docker container

docker run --runtime nvidia --gpus all -v ~/.cache/huggingface:/root/.cache/huggingface -p 8000:8000 --env "HUGGING_FACE_HUB_TOKEN=[MY_TOKEN_HERE]"  vllm/vllm-openai --model google/paligemma-3b-mix-224

And after it is up & running, I execute the following python code

import base64

import requests
from openai import OpenAI

# Modify OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8000/v1"

client = OpenAI(
    # defaults to os.environ.get("OPENAI_API_KEY")
    api_key=openai_api_key,
    base_url=openai_api_base,
)

models = client.models.list()
model = models.data[0].id

image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"

# Use base64 encoded image in the payload
def encode_image_base64_from_url(image_url: str) -> str:
    """Encode an image retrieved from a remote url to base64 format."""

    with requests.get(image_url) as response:
        response.raise_for_status()
        return base64.b64encode(response.content).decode('utf-8')


image_base64 = encode_image_base64_from_url(image_url=image_url)
chat_completion_from_base64 = client.chat.completions.create(
    messages=[{
        "role":
        "user",
        "content": [
            {
                "type": "text",
                "text": "USER: <image>\nWhat is the content of this image?\nASSISTANT:",
            },
            {
                "type": "image_url",
                "image_url": {
                    "url": f"data:image/jpeg;base64,{image_base64}"
                },
            },
        ],
    }],
    model=model,
)

result = chat_completion_from_base64.choices[0].message.content

print(f"Chat completion output:{result}")

This results in the following ooutput:

Chat completion output:<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>
<|im_end>

Please help.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Hey @arseniybelkov I just want to let you know this is still on my list of TODO but I simply had limited bandwidth with other priorities. Sorry for the inconvenience!

@ywang96 Here is the code and image

from vllm import LLM

from PIL import Image
import PIL
import requests
from io import BytesIO
from transformers import AutoTokenizer
import torch


MODEL_ID = "google/paligemma-3b-mix-224"

image = Image.open("Notre-Dame_de_Paris,_4_October_2017.jpg")

# Refer to the HuggingFace repo for the correct format to use
prompt = "caption en"

# Load the image using PIL.Image
llm = LLM(model=MODEL_ID, tokenizer=MODEL_ID, dtype=torch.float32)
# Single prompt inference
outputs = llm.generate({
    "prompt": prompt,
    "multi_modal_data": {"image": image},
})

for o in outputs:
    generated_text = o.outputs[0].text
    print(generated_text)