vllm-project / vllm

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

[Bug]: 8xV100 gpus: Failed to infer device type #8885

Closed ergleb78 closed 6 days ago

ergleb78 commented 6 days ago

Your current environment

I'm trying to run inference in docker-compose, host: ubuntu 22.04

uname -r
5.19.0-1010-nvidia-lowlatency
version: '3.8'

services:
  mixtral7x8b:
    image: vllm/vllm-openai:v0.5.5
    restart: unless-stopped
    ports:
      - "100.73.239.219:8000:8000"
    volumes:
      - /opt/ai_models:/models
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: [gpu]
    environment:
      - VLLM_API_KEY=<token here>
      # parameters for uvicorn (seconds)
      - TIMEOUT_KEEP_ALIVE=120
      - TIMEOUT_GRACEFUL_SHUTDOWN=30
    runtime: nvidia
    shm_size: 100gb
    command: >
      --host 0.0.0.0
      --dtype=half
      --served-model-name Mixtral-8x7b
      --model /models/mistralai/Mixtral-8x7B-Instruct-v0.1
nvidia-smi
Fri Sep 27 04:43:53 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.90.12              Driver Version: 550.90.12      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Tesla V100-SXM3-32GB           Off |   00000000:1A:00.0 Off |                    0 |
| N/A   35C    P0             53W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  Tesla V100-SXM3-32GB           Off |   00000000:1C:00.0 Off |                    0 |
| N/A   34C    P0             49W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   2  Tesla V100-SXM3-32GB           Off |   00000000:1D:00.0 Off |                    0 |
| N/A   36C    P0             56W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   3  Tesla V100-SXM3-32GB           Off |   00000000:1E:00.0 Off |                    0 |
| N/A   37C    P0             53W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   4  Tesla V100-SXM3-32GB           Off |   00000000:3E:00.0 Off |                    0 |
| N/A   38C    P0             57W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   5  Tesla V100-SXM3-32GB           Off |   00000000:3F:00.0 Off |                    0 |
| N/A   35C    P0             57W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   6  Tesla V100-SXM3-32GB           Off |   00000000:40:00.0 Off |                    0 |
| N/A   37C    P0             53W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   7  Tesla V100-SXM3-32GB           Off |   00000000:41:00.0 Off |                    0 |
| N/A   35C    P0             59W /  350W |       1MiB /  32768MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

Model Input Dumps

No response

🐛 Describe the bug

mixtral7x8b-1  | INFO 09-26 21:36:47 api_server.py:144] Multiprocessing frontend to use ipc:///tmp/32318298-afda-4100-99be-34a8f1cfb8ea for RPC Path.
mixtral7x8b-1  | INFO 09-26 21:36:47 api_server.py:161] Started engine process with PID 79
mixtral7x8b-1  | WARNING 09-26 21:36:56 config.py:1563] Casting torch.bfloat16 to torch.float16.
mixtral7x8b-1  | INFO 09-26 21:36:56 llm_engine.py:184] Initializing an LLM engine (v0.5.5) with config: model='/models/mistralai/Mixtral-8x7B-Instruct-v0.1', speculative_config=None, tokenizer='/models/mistralai/Mixtral-8x7B-Instruct-v0.1', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, rope_scaling=None, rope_theta=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.float16, max_seq_len=32768, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=1, pipeline_parallel_size=1, disable_custom_all_reduce=False, quantization=None, enforce_eager=False, kv_cache_dtype=auto, quantization_param_path=None, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='outlines'), observability_config=ObservabilityConfig(otlp_traces_endpoint=None, collect_model_forward_time=False, collect_model_execute_time=False), seed=0, served_model_name=Mixtral-8x7b, use_v2_block_manager=False, enable_prefix_caching=False)
mixtral7x8b-1  | Process SpawnProcess-1:
mixtral7x8b-1  | Traceback (most recent call last):
mixtral7x8b-1  |   File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
mixtral7x8b-1  |     self.run()
mixtral7x8b-1  |   File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
mixtral7x8b-1  |     self._target(*self._args, **self._kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/entrypoints/openai/rpc/server.py", line 230, in run_rpc_server
mixtral7x8b-1  |     server = AsyncEngineRPCServer(async_engine_args, usage_context, rpc_path)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/entrypoints/openai/rpc/server.py", line 31, in __init__
mixtral7x8b-1  |     self.engine = AsyncLLMEngine.from_engine_args(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/engine/async_llm_engine.py", line 740, in from_engine_args
mixtral7x8b-1  |     engine = cls(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/engine/async_llm_engine.py", line 636, in __init__
mixtral7x8b-1  |     self.engine = self._init_engine(*args, **kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/engine/async_llm_engine.py", line 840, in _init_engine
mixtral7x8b-1  |     return engine_class(*args, **kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/engine/async_llm_engine.py", line 272, in __init__
mixtral7x8b-1  |     super().__init__(*args, **kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/engine/llm_engine.py", line 270, in __init__
mixtral7x8b-1  |     self.model_executor = executor_class(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/executor/executor_base.py", line 46, in __init__
mixtral7x8b-1  |     self._init_executor()
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/executor/gpu_executor.py", line 37, in _init_executor
mixtral7x8b-1  |     self.driver_worker = self._create_worker()
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/executor/gpu_executor.py", line 104, in _create_worker
mixtral7x8b-1  |     return create_worker(**self._get_create_worker_kwargs(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/executor/gpu_executor.py", line 23, in create_worker
mixtral7x8b-1  |     wrapper.init_worker(**kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/worker_base.py", line 444, in init_worker
mixtral7x8b-1  |     self.worker = worker_class(*args, **kwargs)
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/worker.py", line 99, in __init__
mixtral7x8b-1  |     self.model_runner: GPUModelRunnerBase = ModelRunnerClass(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/worker/model_runner.py", line 842, in __init__
mixtral7x8b-1  |     self.attn_backend = get_attn_backend(
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/attention/selector.py", line 108, in get_attn_backend
mixtral7x8b-1  |     backend = which_attn_to_use(num_heads, head_size, num_kv_heads,
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/attention/selector.py", line 215, in which_attn_to_use
mixtral7x8b-1  |     if current_platform.get_device_capability()[0] < 8:
mixtral7x8b-1  |   File "/usr/local/lib/python3.10/dist-packages/vllm/platforms/interface.py", line 28, in get_device_capability
mixtral7x8b-1  |     raise NotImplementedError
mixtral7x8b-1  | NotImplementedError
mixtral7x8b-1  | ERROR 09-26 21:36:57 api_server.py:171] RPCServer process died before responding to readiness probe

It used to work just few hours ago, we simply restarted docker compose, same image, same tag, same mode. Not sure what might have happened

Why did it start checking compute capability <8 if it used to run on 7 just a day ago? I appreciate your help, I almost broke my head already.

on v0.6.2 getting a different error:

llama-3.1-8b-1  | Process SpawnProcess-1:
llama-3.1-8b-1  | Traceback (most recent call last):
llama-3.1-8b-1  |   File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
llama-3.1-8b-1  |     self.run()
llama-3.1-8b-1  |   File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
llama-3.1-8b-1  |     self._target(*self._args, **self._kwargs)
llama-3.1-8b-1  |   File "/usr/local/lib/python3.12/dist-packages/vllm/engine/multiprocessing/engine.py", line 388, in run_mp_engine
llama-3.1-8b-1  |     engine = MQLLMEngine.from_engine_args(engine_args=engine_args,
llama-3.1-8b-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-3.1-8b-1  |   File "/usr/local/lib/python3.12/dist-packages/vllm/engine/multiprocessing/engine.py", line 134, in from_engine_args
llama-3.1-8b-1  |     engine_config = engine_args.create_engine_config()
llama-3.1-8b-1  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-3.1-8b-1  |   File "/usr/local/lib/python3.12/dist-packages/vllm/engine/arg_utils.py", line 873, in create_engine_config
llama-3.1-8b-1  |     device_config = DeviceConfig(device=self.device)
llama-3.1-8b-1  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
llama-3.1-8b-1  |   File "/usr/local/lib/python3.12/dist-packages/vllm/config.py", line 1081, in __init__
llama-3.1-8b-1  |     raise RuntimeError("Failed to infer device type")
llama-3.1-8b-1  | RuntimeError: Failed to infer device type

Before submitting a new issue...

DarkLight1337 commented 6 days ago

As a sanity check, can you import pytorch and verify that it can access your GPUs?

ergleb78 commented 6 days ago

@DarkLight1337

Absolutely. I'm not sure if this is the good way to test it, but this is what poped up instantly:

import torch

def check_pytorch_gpu():
    try:
        if torch.cuda.is_available():
            print(f"PyTorch can access {torch.cuda.device_count()} GPU(s).")
            for i in range(torch.cuda.device_count()):
                print(f"GPU {i}: {torch.cuda.get_device_name(i)}")
        else:
            print("PyTorch cannot access any GPUs.")
    except Exception as e:
        print(f"An error occurred: {e}")

if __name__ == "__main__":
    check_pytorch_gpu()

pyproject.toml

[tool.poetry]
name = "try-gpus"
version = "0.1.0"
description = ""
authors = ["Gleb Erokhin"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
torch = "^2.4.1"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Execution output:

PyTorch can access 8 GPU(s).
GPU 0: Tesla V100-SXM3-32GB
GPU 1: Tesla V100-SXM3-32GB
GPU 2: Tesla V100-SXM3-32GB
GPU 3: Tesla V100-SXM3-32GB
GPU 4: Tesla V100-SXM3-32GB
GPU 5: Tesla V100-SXM3-32GB
GPU 6: Tesla V100-SXM3-32GB
GPU 7: Tesla V100-SXM3-32GB
DarkLight1337 commented 6 days ago

Perhaps you can try upgrading the vLLM version. It's possible that this issue has been fixed since v0.5.5.

DarkLight1337 commented 6 days ago

Otherwise I'm not sure. @youkaichao any ideas?

youkaichao commented 6 days ago

please run https://github.com/vllm-project/vllm/blob/main/collect_env.py inside the docker image to collect the environment.

ergleb78 commented 6 days ago

Perhaps you can try upgrading the vLLM version. It's possible that this issue has been fixed since v0.5.5.

Yeah, I tried that with v9.6.2 (posted the results above). Getting “Failed to infer device type” exception. I will run the python script in the container and post here, as requested.

ergleb78 commented 6 days ago

please run https://github.com/vllm-project/vllm/blob/main/collect_env.py inside the docker image to collect the environment. @youkaichao Here you are. It looks like CUDA is not visible from docker, hovewer nvidia-docker-toolkit seems to be working fine and I can run nvidia-smi from cuda-12-6 container for test.


root@f6ca99dec4b4:/vllm-workspace/ttt# python3 collect_env.py
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 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31

Python version: 3.10.14 (main, Apr  6 2024, 18:45:05) [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.19.0-1010-nvidia-lowlatency-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
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
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          80
On-line CPU(s) list:             0-79
Thread(s) per core:              2
Core(s) per socket:              20
Socket(s):                       2
NUMA node(s):                    2
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           85
Model name:                      Intel(R) Xeon(R) Gold 6138 CPU @ 2.00GHz
Stepping:                        4
CPU MHz:                         999.871
CPU max MHz:                     3700.0000
CPU min MHz:                     1000.0000
BogoMIPS:                        4000.00
Virtualization:                  VT-x
L1d cache:                       1.3 MiB
L1i cache:                       1.3 MiB
L2 cache:                        40 MiB
L3 cache:                        55 MiB
NUMA node0 CPU(s):               0-19,40-59
NUMA node1 CPU(s):               20-39,60-79
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Mitigation; PTI
Vulnerability Mmio stale data:   Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:          Mitigation; IBRS
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, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Mitigation; Clear CPU buffers; SMT vulnerable
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 dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] flashinfer==0.1.4+cu121torch2.4
[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.20
[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.44.2
[pip3] triton==3.0.0
[conda] Could not collect
ROCM Version: Could not collect
Neuron SDK Version: N/A
vLLM Version: 0.5.5
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
Could not collect
ergleb78 commented 6 days ago

Well, I managed to solve the problem in a weird way. I commented the following section in docker compose file

    #deploy:
    # resources:
    #    reservations:
    #      devices:
    #       - driver: nvidia
    #          capabilities: [GPU]

I have no idea why it fixes the issue. Earlier, it was a requirement to explicitly add Nvidia device and GPU capabilities. Maybe it's going to be userful for someone. The problem seems to have nothing to do with VLLM but the container toolkit.

youkaichao commented 6 days ago

thanks for reporting, you need to make cuda work before you can use vllm.