vllm-project / vllm

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

[Bug]: Docker image starts vllm.entrypoints.openai.api_server , Docker opens port 8000 but vllm isn't listening on 8000 #5366

Closed elabz closed 5 months ago

elabz commented 5 months ago

Your current environment

Please note this is inside a Docker container built locally, so the collect_env.py was run as docker exec -it vllm-openai sh -c '/usr/bin/python3 /vllm-workspace/collect_env.py'


docker exec -it vllm-openai sh -c '/usr/bin/python3 /vllm-workspace/collect_env.py'
Collecting environment information...
logging interval: 5
PyTorch version: 2.3.0+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.29.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-6.8.0-35-generic-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 P104-100
Nvidia driver version: 550.78
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):                               4
On-line CPU(s) list:                  0-3
Vendor ID:                            GenuineIntel
Model name:                           Intel(R) Core(TM) i5-7500T CPU @ 2.70GHz
CPU family:                           6
Model:                                158
Thread(s) per core:                   1
Core(s) per socket:                   4
Socket(s):                            1
Stepping:                             9
CPU max MHz:                          3300.0000
CPU min MHz:                          800.0000
BogoMIPS:                             5399.81
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 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization:                       VT-x
L1d cache:                            128 KiB (4 instances)
L1i cache:                            128 KiB (4 instances)
L2 cache:                             1 MiB (4 instances)
L3 cache:                             6 MiB (1 instance)
NUMA node(s):                         1
NUMA node0 CPU(s):                    0-3
Vulnerability Gather data sampling:   Mitigation; Microcode
Vulnerability Itlb multihit:          KVM: Mitigation: VMX disabled
Vulnerability L1tf:                   Mitigation; PTE Inversion; VMX conditional cache flushes, SMT disabled
Vulnerability Mds:                    Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Meltdown:               Mitigation; PTI
Vulnerability Mmio stale data:        Mitigation; Clear CPU buffers; SMT disabled
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed:               Mitigation; IBRS
Vulnerability Spec rstack overflow:   Not affected
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; IBRS; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                  Mitigation; Microcode
Vulnerability Tsx async abort:        Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] nvidia-nccl-cu12==2.20.5
[pip3] torch==2.3.0
[pip3] transformers==4.41.2
[pip3] triton==2.3.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.4.3
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X  0-3 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

Verify Python process is working inside the container:

docker exec -it vllm-openai ps -ef ww
UID          PID    PPID  C STIME TTY      STAT   TIME CMD
root           1       0 96 14:35 ?        Rsl    5:13 python3 -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --port 8000 --model=astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit --enforce-eager --dtype=half --gpu-memory-utilization 0.95 --tensor-parallel-size=1
root          59       0  0 14:40 pts/0    Rs+    0:00 ps -ef ww

install nettools: docker exec -it vllm-openai apt-get install net-tools

verify ports open on container:

docker exec -it vllm-openai netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 172.17.0.2:37769        0.0.0.0:*               LISTEN      1/python3
tcp        0      0 172.17.0.2:49279        0.0.0.0:*               LISTEN      1/python3
tcp        0      0 172.17.0.2:33465        0.0.0.0:*               LISTEN      1/python3
tcp6       0      0 :::34315                :::*                    LISTEN      1/python3

It listens, just not on 8000 despite the --port 8000 directive in the command

Docker has port 8000 open and forwarded:

docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED       STATUS          PORTS                                       NAMES
5d6972460ce0   vllm/vllm-openai   "python3 -m vllm.ent…"   2 hours ago   Up 26 minutes   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   vllm-openai

According to the container logs the model appears to be loading (which is also confirmed by running nvtop and seeing VRAM memory usage and GPU activity

docker logs -f vllm-openai

INFO 06-09 14:35:15 api_server.py:177] vLLM API server version 0.4.3
INFO 06-09 14:35:15 api_server.py:178] args: Namespace(host='0.0.0.0', port=8000, uvicorn_log_level='info', allow_credentials=False, allowed_origins=['*'], allowed_methods=['*'], allowed_headers=['*'], api_key=None, lora_modules=None, chat_template=None, response_role='assistant', ssl_keyfile=None, ssl_certfile=None, ssl_ca_certs=None, ssl_cert_reqs=0, root_path=None, middleware=[], model='astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit', 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', dtype='half', 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=1, 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, gpu_memory_utilization=0.95, num_gpu_blocks_override=None, max_num_batched_tokens=None, max_num_seqs=256, max_logprobs=5, disable_log_stats=False, quantization=None, rope_scaling=None, enforce_eager=True, 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, 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, device='auto', image_input_type=None, image_token_id=None, image_input_shape=None, image_feature_size=None, scheduler_delay_factor=0.0, enable_chunked_prefill=False, speculative_model=None, num_speculative_tokens=None, speculative_max_model_len=None, speculative_disable_by_batch_size=None, ngram_prompt_lookup_max=None, ngram_prompt_lookup_min=None, model_loader_extra_config=None, served_model_name=None, qlora_adapter_name_or_path=None, engine_use_ray=False, disable_log_requests=False, max_log_len=None)
/usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
WARNING 06-09 14:35:15 config.py:1162] Casting torch.bfloat16 to torch.float16.
WARNING 06-09 14:35:15 config.py:213] gptq quantization is not fully optimized yet. The speed can be slower than non-quantized models.
INFO 06-09 14:35:15 llm_engine.py:163] Initializing an LLM engine (v0.4.3) with config: model='astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit', speculative_config=None, tokenizer='astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, rope_scaling=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.float16, max_seq_len=8192, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=1, disable_custom_all_reduce=False, quantization=gptq, enforce_eager=True, kv_cache_dtype=auto, quantization_param_path=None, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='outlines'), seed=0, served_model_name=astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit)
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.
INFO 06-09 14:35:16 selector.py:120] Cannot use FlashAttention-2 backend for Volta and Turing GPUs.
INFO 06-09 14:35:16 selector.py:51] Using XFormers backend.
INFO 06-09 14:35:18 selector.py:120] Cannot use FlashAttention-2 backend for Volta and Turing GPUs.
INFO 06-09 14:35:18 selector.py:51] Using XFormers backend.
INFO 06-09 14:35:19 weight_utils.py:221] Using model weights format ['*.safetensors']
INFO 06-09 14:35:19 weight_utils.py:264] No model.safetensors.index.json found in remote.
INFO 06-09 14:35:55 model_runner.py:146] Loading model weights took 5.3472 GB

🐛 Describe the bug

try getting any output from the API, get Connection Reset by Peer error:

curl http://localhost:8000/v1/models
curl: (56) Recv failure: Connection reset by peer

Any help or nudge in the right direction will be greatly appreciated!

elabz commented 5 months ago

One more detail - Docker container was started as

    docker run -d \
    --shm-size=10.24gb \
    --gpus '"device=2"' \
    -v /data/models:/root/.cache/huggingface \
    --env "HF_TOKEN=ma_token" \
    -p 8000:8000 \
    --restart unless-stopped \
    --name vllm-openai \
    vllm/vllm-openai \
    --host 0.0.0.0 \
    --port 8000 \
    --model=astronomer/Llama-3-8B-Instruct-GPTQ-4-Bit \
    --enforce-eager \
    --dtype=half \
    --gpu-memory-utilization 0.95 \
    --tensor-parallel-size=1
elabz commented 5 months ago

I am closing it myself - the issue appears to be in loading the model - the python script never gets to the uvicorn section, so the actual server on 8000 never starts, even those the python script is running

paulinergt commented 4 months ago

Hello ! I have the same issue... Did you solve it ? I am very interested if you have any solution :) Thank you !

rmrbytes commented 4 months ago

Hello. I am facing a similar issue. Is there a solution for this? Thanks

logankeenan commented 2 weeks ago

TLDR: The model is still being downloaded. You need to wait until INFO: Uvicorn running on socket ('0.0.0.0', 8000) (Press CTRL+C to quit) is in the logs before you can call it.

I originally tried this with mistral. I did notice my network usage was really high, but didn't think much of it.

docker run --network=host --runtime=nvidia --gpus all \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  --env "HUGGING_FACE_HUB_TOKEN=$HF_TOKEN" \
  --ipc=host \
  vllm/vllm-openai:latest \
  --model mistralai/Mistral-7B-v0.1 \
  --tokenizer_mode "mistral"

However, I tried another smaller bloom-560. Same high network usage, but it eventually went to ~0 and the logs make progress. I was able to test and model and get a response.

docker run --runtime=nvidia --gpus all \
  -v ~/.cache/huggingface:/root/.cache/huggingface \
  -p 8000:8000 \
  --ipc=host \
  vllm/vllm-openai:latest \
  --model bigscience/bloom-560m
curl -X POST http://localhost:8000/v1/completions -H "Content-Type: application/json" -d '{
  "model": "bigscience/bloom-560m",
  "prompt": "Once upon a time",
  "max_tokens": 50,
  "temperature": 0.7
}'

image

@rmr-code @paulinergt