vllm
vllm copied to clipboard
[Bug]: RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
I have updated to the latest version and used the “spawn” method,
export VLLM_WORKER_MULTIPROC_METHOD=spawn
but the error still persists. Could you please help me?
my code
from vllm import LLM, SamplingParams
import torch
# # 检查是否有GPU可用
device = "cuda" if torch.cuda.is_available() else "cpu"
# 推理数据以List[str]格式组织
prompts = [
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
# 设置采样参数
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
# 加载模型,并指定设备为GPU
llm = LLM(model="Qwen/Qwen2.5-32B-Instruct", device=device, tensor_parallel_size=2, trust_remote_code=True)
# 执行推理
outputs = llm.generate(prompts, sampling_params)
# 输出推理结果
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
You can try commenting out or deleting :
'device = "cuda" if torch.cuda.is_available() else "cpu"
Thanks, it works. But I got an error:
ERROR 09-27 17:51:52 multiproc_worker_utils.py:120] Worker VllmWorkerProcess pid 26713 died, exit code: 1
INFO 09-27 17:51:52 multiproc_worker_utils.py:123] Killing local vLLM worker processes
Processed prompts: 0%| | 0/4 [00:00<?, ?it/s, est. speed input: 0.00 toks/s, output: 0.00 toks/s]
Processed prompts: 25%|██▌ | 1/4 [00:00<00:00, 3.73it/s, est. speed input: 22.37 toks/s, output: 59.64 toks/s]
Processed prompts: 100%|██████████| 4/4 [00:00<00:00, 14.90it/s, est. speed input: 96.85 toks/s, output: 238.40 toks/s]
[rank0]:[W927 17:49:14.927366122 CudaIPCTypes.cpp:16] Producer process has been terminated before all shared CUDA tensors released. See Note [Sharing CUDA tensors]
/home/test/test07/miniconda3/envs/op/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
Can you show the full stack trace?
Here:
INFO 09-27 18:05:57 config.py:899] Defaulting to use mp for distributed inference
WARNING 09-27 18:05:57 arg_utils.py:930] Chunked prefill is enabled by default for models with max_model_len > 32K. Currently, chunked prefill might not work with some features or models. If you encounter any issues, please disable chunked prefill by setting --enable-chunked-prefill=False.
INFO 09-27 18:05:57 config.py:1010] Chunked prefill is enabled with max_num_batched_tokens=512.
INFO 09-27 18:05:57 llm_engine.py:226] Initializing an LLM engine (v0.6.1.dev238+ge2c6e0a82) with config: model='/home/test/test07/hechaoqun/download_models/internlm/internlm2-chat-7b', speculative_config=None, tokenizer='/home/test/test07/hechaoqun/download_models/internlm/internlm2-chat-7b', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, override_neuron_config=None, rope_scaling=None, rope_theta=None, tokenizer_revision=None, trust_remote_code=True, dtype=torch.bfloat16, max_seq_len=65536, download_dir=None, load_format=LoadFormat.AUTO, tensor_parallel_size=2, 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=/home/test/test07/hechaoqun/download_models/internlm/internlm2-chat-7b, use_v2_block_manager=False, num_scheduler_steps=1, multi_step_stream_outputs=False, enable_prefix_caching=False, use_async_output_proc=True, use_cached_outputs=False, mm_processor_kwargs=None)
INFO 09-27 18:05:57 custom_cache_manager.py:17] Setting Triton cache manager to: vllm.triton_utils.custom_cache_manager:CustomCacheManager
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:05:58 multiproc_worker_utils.py:218] Worker ready; awaiting tasks
INFO 09-27 18:05:59 utils.py:992] Found nccl from library libnccl.so.2
INFO 09-27 18:05:59 pynccl.py:63] vLLM is using nccl==2.20.5
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:05:59 utils.py:992] Found nccl from library libnccl.so.2
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:05:59 pynccl.py:63] vLLM is using nccl==2.20.5
INFO 09-27 18:06:02 custom_all_reduce_utils.py:242] reading GPU P2P access cache from /home/test/test07/.cache/vllm/gpu_p2p_access_cache_for_0,1.json
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:02 custom_all_reduce_utils.py:242] reading GPU P2P access cache from /home/test/test07/.cache/vllm/gpu_p2p_access_cache_for_0,1.json
INFO 09-27 18:06:02 shm_broadcast.py:241] vLLM message queue communication handle: Handle(connect_ip='127.0.0.1', local_reader_ranks=[1], buffer=<vllm.distributed.device_communicators.shm_broadcast.ShmRingBuffer object at 0x7f4c46bce380>, local_subscribe_port=60099, remote_subscribe_port=None)
INFO 09-27 18:06:02 model_runner.py:1014] Starting to load model /home/test/test07/hechaoqun/download_models/internlm/internlm2-chat-7b...
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:02 model_runner.py:1014] Starting to load model /home/test/test07/hechaoqun/download_models/internlm/internlm2-chat-7b...
INFO 09-27 18:06:11 model_runner.py:1025] Loading model weights took 7.2232 GB
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:11 model_runner.py:1025] Loading model weights took 7.2232 GB
INFO 09-27 18:06:16 distributed_gpu_executor.py:57] # GPU blocks: 63651, # CPU blocks: 4096
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:19 model_runner.py:1329] Capturing the model for CUDA graphs. This may lead to unexpected consequences if the model is not static. To run the model in eager mode, set 'enforce_eager=True' or use '--enforce-eager' in the CLI.
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:19 model_runner.py:1333] CUDA graphs can take additional 1~3 GiB memory per GPU. If you are running out of memory, consider decreasing `gpu_memory_utilization` or enforcing eager mode. You can also reduce the `max_num_seqs` as needed to decrease memory usage.
INFO 09-27 18:06:19 model_runner.py:1329] Capturing the model for CUDA graphs. This may lead to unexpected consequences if the model is not static. To run the model in eager mode, set 'enforce_eager=True' or use '--enforce-eager' in the CLI.
INFO 09-27 18:06:19 model_runner.py:1333] CUDA graphs can take additional 1~3 GiB memory per GPU. If you are running out of memory, consider decreasing `gpu_memory_utilization` or enforcing eager mode. You can also reduce the `max_num_seqs` as needed to decrease memory usage.
INFO 09-27 18:06:43 custom_all_reduce.py:229] Registering 2275 cuda graph addresses
INFO 09-27 18:06:43 model_runner.py:1456] Graph capturing finished in 24 secs.
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:43 custom_all_reduce.py:229] Registering 2275 cuda graph addresses
[1;36m(VllmWorkerProcess pid=28018)[0;0m INFO 09-27 18:06:43 model_runner.py:1456] Graph capturing finished in 24 secs.
Prompt: 'Hello, my name is', Generated text: ' Lorena. I am a native Spanish speaker who loves teaching Spanish to anyone who'
Prompt: 'The president of the United States is', Generated text: ' the head of state of the United States and is further empowered to grant federal'
Prompt: 'The capital of France is', Generated text: ' Paris. The population of the city is about 2.1 million. Paris'
Prompt: 'The future of AI is', Generated text: ' bright\nArtificial Intelligence (AI) is an ever-evolving technology,'
ERROR 09-27 18:06:45 multiproc_worker_utils.py:120] Worker VllmWorkerProcess pid 28018 died, exit code: -15
INFO 09-27 18:06:45 multiproc_worker_utils.py:124] Killing local vLLM worker processes
Can you run collect_env.py and post the output? cc @youkaichao
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: CentOS Linux 7 (Core) (x86_64)
GCC version: (conda-forge gcc 10.4.0-17) 10.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.17
Python version: 3.10.14 (main, May 6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-3.10.0-1160.el7.x86_64-x86_64-with-glibc2.17
Is CUDA available: True
CUDA runtime version: 12.1.66
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA A800-SXM4-80GB
GPU 1: NVIDIA A800-SXM4-80GB
GPU 2: NVIDIA A800-SXM4-80GB
GPU 3: NVIDIA A800-SXM4-80GB
GPU 4: NVIDIA A800-SXM4-80GB
GPU 5: NVIDIA A800-SXM4-80GB
GPU 6: NVIDIA A800-SXM4-80GB
GPU 7: NVIDIA A800-SXM4-80GB
Nvidia driver version: 535.183.06
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
Byte Order: Little Endian
CPU(s): 104
On-line CPU(s) list: 0-103
Thread(s) per core: 1
Core(s) per socket: 52
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 143
Model name: Intel(R) Xeon(R) Platinum 8470
Stepping: 8
CPU MHz: 3799.926
CPU max MHz: 3800.0000
CPU min MHz: 800.0000
BogoMIPS: 4000.00
Virtualization: VT-x
L1d cache: 48K
L1i cache: 32K
L2 cache: 2048K
L3 cache: 107520K
NUMA node0 CPU(s): 0-51
NUMA node1 CPU(s): 52-103
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 aperfmperf eagerfpu 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 epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_pt cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq cldemote movdiri movdir64b md_clear pconfig spec_ctrl intel_stibp flush_l1d arch_capabilities
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.68
[pip3] nvidia-nvtx-cu12==12.1.105
[pip3] pyzmq==26.2.0
[pip3] sentence-transformers==2.2.2
[pip3] torch==2.4.0
[pip3] torchvision==0.19.0
[pip3] transformers==4.45.1
[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.68 pypi_0 pypi
[conda] nvidia-nvtx-cu12 12.1.105 pypi_0 pypi
[conda] pyzmq 26.2.0 pypi_0 pypi
[conda] sentence-transformers 2.2.2 pypi_0 pypi
[conda] torch 2.4.0 pypi_0 pypi
[conda] torchvision 0.19.0 pypi_0 pypi
[conda] transformers 4.45.1 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.1.dev238+ge2c6e0a82
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; Neuron: Disabled
GPU Topology:
GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 NIC0 NIC1 NIC2 NIC3 NIC4 NIC5 NIC6 NIC7 NIC8 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NV8 NV8 NV8 NV8 NV8 NV8 NV8 PXB NODE NODE NODE SYS SYS SYS SYS SYS 0-51 0 N/A
GPU1 NV8 X NV8 NV8 NV8 NV8 NV8 NV8 NODE PXB NODE NODE SYS SYS SYS SYS SYS 0-51 0 N/A
GPU2 NV8 NV8 X NV8 NV8 NV8 NV8 NV8 NODE NODE PXB NODE SYS SYS SYS SYS SYS 0-51 0 N/A
GPU3 NV8 NV8 NV8 X NV8 NV8 NV8 NV8 NODE NODE NODE PXB SYS SYS SYS SYS SYS 0-51 0 N/A
GPU4 NV8 NV8 NV8 NV8 X NV8 NV8 NV8 SYS SYS SYS SYS PXB NODE NODE NODE NODE 52-103 1 N/A
GPU5 NV8 NV8 NV8 NV8 NV8 X NV8 NV8 SYS SYS SYS SYS NODE NODE PXB NODE NODE 52-103 1 N/A
GPU6 NV8 NV8 NV8 NV8 NV8 NV8 X NV8 SYS SYS SYS SYS NODE NODE NODE PXB NODE 52-103 1 N/A
GPU7 NV8 NV8 NV8 NV8 NV8 NV8 NV8 X SYS SYS SYS SYS NODE NODE NODE NODE PXB 52-103 1 N/A
NIC0 PXB NODE NODE NODE SYS SYS SYS SYS X NODE NODE NODE SYS SYS SYS SYS SYS
NIC1 NODE PXB NODE NODE SYS SYS SYS SYS NODE X NODE NODE SYS SYS SYS SYS SYS
NIC2 NODE NODE PXB NODE SYS SYS SYS SYS NODE NODE X NODE SYS SYS SYS SYS SYS
NIC3 NODE NODE NODE PXB SYS SYS SYS SYS NODE NODE NODE X SYS SYS SYS SYS SYS
NIC4 SYS SYS SYS SYS PXB NODE NODE NODE SYS SYS SYS SYS X NODE NODE NODE NODE
NIC5 SYS SYS SYS SYS NODE NODE NODE NODE SYS SYS SYS SYS NODE X NODE NODE NODE
NIC6 SYS SYS SYS SYS NODE PXB NODE NODE SYS SYS SYS SYS NODE NODE X NODE NODE
NIC7 SYS SYS SYS SYS NODE NODE PXB NODE SYS SYS SYS SYS NODE NODE NODE X NODE
NIC8 SYS SYS SYS SYS NODE NODE NODE PXB SYS SYS SYS SYS NODE NODE NODE NODE 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
NIC2: mlx5_2
NIC3: mlx5_3
NIC4: mlx5_4
NIC5: mlx5_5
NIC6: mlx5_6
NIC7: mlx5_7
NIC8: mlx5_8
Any progress?
i got the same error when using vllm
This issue has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this issue should remain open. Thank you!
I have the same problem
I am encountering the same issue, waiting for a solution here.
+1
@youkaichao can you take a look at this?
You can try commenting out or deleting :
'device = "cuda" if torch.cuda.is_available() else "cpu"
as pointed by @jeejeelee , the problem is, the users initialized cuda before calling vllm.LLM() , which is incompatible with the default fork approach. If they want to use export VLLM_WORKER_MULTIPROC_METHOD=spawn , then they have to move their code under if __name__ == "__main__" .
the error reported in https://github.com/vllm-project/vllm/issues/8893#issuecomment-2379405305 , is a shutdown error, and the code already finishes. so it can be safely ignored.
You can try commenting out or deleting : 'device = "cuda" if torch.cuda.is_available() else "cpu"
as pointed by @jeejeelee , the problem is, the users initialized cuda before calling
vllm.LLM(), which is incompatible with the defaultforkapproach. If they want to useexport VLLM_WORKER_MULTIPROC_METHOD=spawn, then they have to move their code underif __name__ == "__main__".the error reported in #8893 (comment) , is a shutdown error, and the code already finishes. so it can be safely ignored.
Thanks for your solution @youkaichao .
My Qwen2-72B-Instruct-GPTQ-Int4 vLLM inference code works fine when it was v0.6.6. But I got the same error after upgrade vllm from v0.6.6 to v0.7.3,
and I fixed it by adding export VLLM_WORKER_MULTIPROC_METHOD=spawn and removing device in calling vllm.LLM()
llm = LLM(model="Qwen2-72B-Instruct-GPTQ-Int4", device=device, tensor_parallel_size=2, trust_remote_code=True)
But I am wondering what makes the different, could you provide more details of some reference materials?
Just trying out vLLM for the first time and I ran into this when running python examples/offline_inference/basic/basic.py with VLLM_USE_V1=1.
While spawning works, it would be nice for this to work out of the box. It looks like vllm does CUDA init at import time via cuda_platform_plugin (prior to when it starts forking subprocesses) and forking aside, CUDA init at import is often undesirable in general:
Thread 1 "python" hit Catchpoint 1 (call to syscall openat), 0x00007ffff7dd01e5 in __libc_open64 (file=0x7fffffff7070 "/dev/nvidia0", oflag=524290)
at ../sysdeps/unix/sysv/linux/open64.c:41
warning: 41 ../sysdeps/unix/sysv/linux/open64.c: No such file or directory
(gdb) py-bt
Traceback (most recent call first):
File "/root/code/vllm/vllm/third_party/pynvml.py", line 2380, in nvmlInitWithFlags
ret = fn(flags)
File "/root/code/vllm/vllm/third_party/pynvml.py", line 2391, in nvmlInit
nvmlInitWithFlags(0)
File "/root/code/vllm/vllm/platforms/__init__.py", line 57, in cuda_platform_plugin
pynvml.nvmlInit()
File "/root/code/vllm/vllm/platforms/__init__.py", line 230, in resolve_current_platform_cls_qualname
platform_cls_qualname = func()
File "/root/code/vllm/vllm/platforms/__init__.py", line 287, in __getattr__
platform_cls_qualname = resolve_current_platform_cls_qualname()
File "<frozen importlib._bootstrap>", line 1229, in _handle_fromlist
File "/root/code/vllm/vllm/model_executor/layers/spec_decode_base_sampler.py", line 10, in <module>
from vllm.platforms import current_platform
<built-in method exec of module object at remote 0x7ffff78f8a90>
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "/root/code/vllm/vllm/spec_decode/metrics.py", line 9, in <module>
from vllm.model_executor.layers.spec_decode_base_sampler import (
<built-in method exec of module object at remote 0x7ffff78f8a90>
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "/root/code/vllm/vllm/model_executor/layers/sampler.py", line 23, in <module>
from vllm.spec_decode.metrics import SpecDecodeWorkerMetrics
...
(this stacktrace might be misleading, in that while it is doing an init, I'm not sure that it triggers the torch fork poison code)
A lot of the import time stuff is easy to unwind, but the registering of ops against vllm.platforms.current_platform.dispatch_key at import time seems a little tricky
@hauntsaninja thanks for the report! which version of vllm are you using? I'm trying the latest version and it works. FYI, you can directly install the latest nightly version with pip install vllm --pre --extra-index-url https://wheels.vllm.ai/nightly . More information can be found at https://blog.vllm.ai/2025/01/10/dev-experience.html
I'm using vllm from commit a21076ed from earlier today. I installed from source (with VLLM_USE_PRECOMPILED=1)
λ VLLM_USE_V1=1 python examples/offline_inference/basic/basic.py
...
ERROR 03-10 02:09:46 [core.py:324] RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
Things work fine without VLLM_USE_V1. As mentioned in this issue, VLLM_WORKER_MULTIPROC_METHOD=spawn + a few simple changes to basic.py fixes when using v1.
that's strange, I'm also working on that commit. Can you provide more information about your environment? e.g. running https://github.com/vllm-project/vllm/blob/main/collect_env.py .
we also have https://github.com/vllm-project/vllm/blob/main/find_cuda_init.py . you can use that to find which line init cuda. it seems to me this might be caused by your environment.
in addition, welcome to join vllm slack https://slack.vllm.ai to chat directly!
I have the same problem when using V1.
Same problem.
- Successfully run with torch==2.5.1 and vllm==0.7.2, without adding
export VLLM_WORKER_MULTIPROC_METHOD=spawnor removing device - The RuntimeError shows when update vllm to 0.8.1 and required torch==2.6.0. But fixes if adding
export VLLM_WORKER_MULTIPROC_METHOD=spawnor removing device
@youkaichao @DarkLight1337 The same problem. In vllm 0.7.3 and vllm 0.8.1 If in vllm 0.7.1 not this problem And I found sometimes.
#/root/anaconda3/lib/python3.12/site-packages/vllm/platforms/interface.py
def is_cuda(self) -> bool:
return self._enum == PlatformEnum.CUDA
self._enum is show 10 on RTX 4090 24GB *1.It should be always 1 not 10.
errorInfo
WARNING 03-21 17:11:14 [utils.py:2282] Methods determine_num_available_blocks,device_config,get_cache_block_size_bytes,initialize_cache not implemented in <vllm.v1.worker.gpu_worker.Worker object at 0x7efba20c0c80>
ERROR 03-21 17:11:14 [core.py:340] EngineCore hit an exception: Traceback (most recent call last):
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 332, in run_engine_core
ERROR 03-21 17:11:14 [core.py:340] engine_core = EngineCoreProc(*args, **kwargs)
ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 287, in __init__
ERROR 03-21 17:11:14 [core.py:340] super().__init__(vllm_config, executor_class, log_stats)
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 59, in __init__
ERROR 03-21 17:11:14 [core.py:340] self.model_executor = executor_class(vllm_config)
ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/executor_base.py", line 52, in __init__
ERROR 03-21 17:11:14 [core.py:340] self._init_executor()
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 46, in _init_executor
ERROR 03-21 17:11:14 [core.py:340] self.collective_rpc("init_device")
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 56, in collective_rpc
ERROR 03-21 17:11:14 [core.py:340] answer = run_method(self.driver_worker, method, args, kwargs)
ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/utils.py", line 2216, in run_method
ERROR 03-21 17:11:14 [core.py:340] return func(*args, **kwargs)
ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/worker/worker_base.py", line 604, in init_device
ERROR 03-21 17:11:14 [core.py:340] self.worker.init_device() # type: ignore
ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/worker/gpu_worker.py", line 103, in init_device
ERROR 03-21 17:11:14 [core.py:340] torch.cuda.set_device(self.device)
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/torch/cuda/__init__.py", line 476, in set_device
ERROR 03-21 17:11:14 [core.py:340] torch._C._cuda_setDevice(device)
ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/torch/cuda/__init__.py", line 305, in _lazy_init
ERROR 03-21 17:11:14 [core.py:340] raise RuntimeError(
ERROR 03-21 17:11:14 [core.py:340] RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
ERROR 03-21 17:11:14 [core.py:340]
CRITICAL 03-21 17:11:14 [core_client.py:269] Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.
If add
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"
will get
INFO 03-21 19:05:49 [__init__.py:256] Automatically detected platform cuda.
MODEL_PATH: /mnt/d/Users/Admin/.cache/modelscope/hub/qwen/Qwen2___5-Coder-0___5B-Instruct-AWQ
INFO 03-21 19:07:27 [config.py:583] This model supports multiple tasks: {'embed', 'reward', 'score', 'generate', 'classify'}. Defaulting to 'generate'.
INFO 03-21 19:07:27 [awq_marlin.py:114] The model is convertible to awq_marlin during runtime. Using awq_marlin kernel.
INFO 03-21 19:07:27 [config.py:1693] Chunked prefill is enabled with max_num_batched_tokens=8192.
WARNING 03-21 19:07:27 [cuda.py:95] To see benefits of async output processing, enable CUDA graph. Since, enforce-eager is enabled, async output processor cannot be used
INFO 03-21 19:07:40 [__init__.py:256] Automatically detected platform cuda.
MODEL_PATH: /mnt/d/Users/Admin/.cache/modelscope/hub/qwen/Qwen2___5-Coder-0___5B-Instruct-AWQ
INFO 03-21 19:07:50 [config.py:583] This model supports multiple tasks: {'embed', 'reward', 'score', 'generate', 'classify'}. Defaulting to 'generate'.
INFO 03-21 19:07:50 [awq_marlin.py:114] The model is convertible to awq_marlin during runtime. Using awq_marlin kernel.
INFO 03-21 19:07:50 [config.py:1693] Chunked prefill is enabled with max_num_batched_tokens=8192.
WARNING 03-21 19:07:50 [cuda.py:95] To see benefits of async output processing, enable CUDA graph. Since, enforce-eager is enabled, async output processor cannot be used
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 131, in _main
prepare(preparation_data)
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/runpy.py", line 287, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/runpy.py", line 98, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/root/anaconda3/lib/python3.12/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/mnt/d/my/work/study/ai/kaggle_code/aimo2/vllm_test.py", line 17, in <module>
llm = vllm.LLM(
^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/utils.py", line 1031, in inner
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/llm.py", line 242, in __init__
self.llm_engine = LLMEngine.from_engine_args(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 137, in from_engine_args
return cls(vllm_config=vllm_config,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 86, in __init__
self.engine_core = EngineCoreClient.make_client(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 66, in make_client
return SyncMPClient(vllm_config, executor_class, log_stats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 337, in __init__
super().__init__(
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 301, in __init__
self.resources.proc_handle = BackgroundProcHandle(
^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/utils.py", line 121, in __init__
self.proc.start()
File "/root/anaconda3/lib/python3.12/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/multiprocessing/context.py", line 289, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/root/anaconda3/lib/python3.12/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/root/anaconda3/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 164, in get_preparation_data
_check_not_importing_main()
File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 140, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
To fix this issue, refer to the "Safe importing of main module"
section in https://docs.python.org/3/library/multiprocessing.html
Then the program freezes.Unable to end.
same here using v1
Same using torch2.6.0 and vllm 0.8.1
Same using torch2.6.0 and vllm 0.8.2
seems like along with export VLLM_WORKER_MULTIPROC_METHOD=spawn, you need to put your vLLM code in if __name__ == "__main__" section or a function, then it works fine.
Update
Adding os.environ['VLLM_WORKER_MULTIPROC_METHOD'] = 'spawn' resolved the issue.
I am having the same issue from running this example (https://qwen.readthedocs.io/en/latest/deployment/vllm.html#offline-batched-inference).
vLLM version 0.8.2.
Code:
import os
os.environ['HF_HOME'] = 'home/scratch/LLM/cache/'
from huggingface_hub import login
hf_token = "hf_mytokenid"
login(token=hf_token)
from transformers import AutoTokenizer
from vllm import LLM, SamplingParams
model_name = "Qwen/Qwen2.5-7B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
llm = LLM(model=model_name)
Error:
INFO 03-29 09:15:54 [config.py:585] This model supports multiple tasks: {'score', 'embed', 'classify', 'reward', 'generate'}. Defaulting to 'generate'.
INFO 03-29 09:15:54 [config.py:1697] Chunked prefill is enabled with max_num_batched_tokens=8192.
INFO 03-29 09:15:56 [core.py:54] Initializing a V1 LLM engine (v0.8.2) with config: model='Qwen/Qwen2.5-7B-Instruct', speculative_config=None, tokenizer='Qwen/Qwen2.5-7B-Instruct', skip_tokenizer_init=False, tokenizer_mode=auto, revision=None, override_neuron_config=None, tokenizer_revision=None, trust_remote_code=False, dtype=torch.bfloat16, 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, device_config=cuda, decoding_config=DecodingConfig(guided_decoding_backend='xgrammar', reasoning_backend=None), observability_config=ObservabilityConfig(show_hidden_metrics=False, otlp_traces_endpoint=None, collect_model_forward_time=False, collect_model_execute_time=False), seed=None, served_model_name=Qwen/Qwen2.5-7B-Instruct, num_scheduler_steps=1, multi_step_stream_outputs=True, enable_prefix_caching=True, chunked_prefill_enabled=True, use_async_output_proc=True, disable_mm_preprocessor_cache=False, mm_processor_kwargs=None, pooler_config=None, compilation_config={"level":3,"custom_ops":["none"],"splitting_ops":["vllm.unified_attention","vllm.unified_attention_with_output"],"use_inductor":true,"compile_sizes":[],"use_cudagraph":true,"cudagraph_num_of_warmups":1,"cudagraph_capture_sizes":[512,504,496,488,480,472,464,456,448,440,432,424,416,408,400,392,384,376,368,360,352,344,336,328,320,312,304,296,288,280,272,264,256,248,240,232,224,216,208,200,192,184,176,168,160,152,144,136,128,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,4,2,1],"max_capture_size":512}
WARNING 03-29 09:16:14 [utils.py:2321] Methods determine_num_available_blocks,device_config,get_cache_block_size_bytes,initialize_cache not implemented in <vllm.v1.worker.gpu_worker.Worker object at 0x1553f1cbea20>
ERROR 03-29 09:16:14 [core.py:343] EngineCore hit an exception: Traceback (most recent call last):
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 335, in run_engine_core
ERROR 03-29 09:16:14 [core.py:343] engine_core = EngineCoreProc(*args, **kwargs)
ERROR 03-29 09:16:14 [core.py:343] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 290, in __init__
ERROR 03-29 09:16:14 [core.py:343] super().__init__(vllm_config, executor_class, log_stats)
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 60, in __init__
ERROR 03-29 09:16:14 [core.py:343] self.model_executor = executor_class(vllm_config)
ERROR 03-29 09:16:14 [core.py:343] ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/executor/executor_base.py", line 52, in __init__
ERROR 03-29 09:16:14 [core.py:343] self._init_executor()
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 46, in _init_executor
ERROR 03-29 09:16:14 [core.py:343] self.collective_rpc("init_device")
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 56, in collective_rpc
ERROR 03-29 09:16:14 [core.py:343] answer = run_method(self.driver_worker, method, args, kwargs)
ERROR 03-29 09:16:14 [core.py:343] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/utils.py", line 2255, in run_method
ERROR 03-29 09:16:14 [core.py:343] return func(*args, **kwargs)
ERROR 03-29 09:16:14 [core.py:343] ^^^^^^^^^^^^^^^^^^^^^
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/worker/worker_base.py", line 604, in init_device
ERROR 03-29 09:16:14 [core.py:343] self.worker.init_device() # type: ignore
ERROR 03-29 09:16:14 [core.py:343] ^^^^^^^^^^^^^^^^^^^^^^^^^
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/vllm/v1/worker/gpu_worker.py", line 103, in init_device
ERROR 03-29 09:16:14 [core.py:343] torch.cuda.set_device(self.device)
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/torch/cuda/__init__.py", line 476, in set_device
ERROR 03-29 09:16:14 [core.py:343] torch._C._cuda_setDevice(device)
ERROR 03-29 09:16:14 [core.py:343] File "home/.conda/envs/vllm/lib/python3.12/site-packages/torch/cuda/__init__.py", line 305, in _lazy_init
ERROR 03-29 09:16:14 [core.py:343] raise RuntimeError(
ERROR 03-29 09:16:14 [core.py:343] RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
ERROR 03-29 09:16:14 [core.py:343]
CRITICAL 03-29 09:16:15 [core_client.py:269] Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.
Same issue. On vllm 0.8.5.post1, no solutions have worked.
@youkaichao @DarkLight1337 The same problem. In vllm 0.7.3 and vllm 0.8.1 If in vllm 0.7.1 not this problem And I found sometimes.
#/root/anaconda3/lib/python3.12/site-packages/vllm/platforms/interface.py def is_cuda(self) -> bool: return self._enum == PlatformEnum.CUDAself._enum is show 10 on RTX 4090 24GB *1.It should be always 1 not 10.
errorInfo
WARNING 03-21 17:11:14 [utils.py:2282] Methods determine_num_available_blocks,device_config,get_cache_block_size_bytes,initialize_cache not implemented in <vllm.v1.worker.gpu_worker.Worker object at 0x7efba20c0c80> ERROR 03-21 17:11:14 [core.py:340] EngineCore hit an exception: Traceback (most recent call last): ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 332, in run_engine_core ERROR 03-21 17:11:14 [core.py:340] engine_core = EngineCoreProc(*args, **kwargs) ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 287, in __init__ ERROR 03-21 17:11:14 [core.py:340] super().__init__(vllm_config, executor_class, log_stats) ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core.py", line 59, in __init__ ERROR 03-21 17:11:14 [core.py:340] self.model_executor = executor_class(vllm_config) ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/executor_base.py", line 52, in __init__ ERROR 03-21 17:11:14 [core.py:340] self._init_executor() ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 46, in _init_executor ERROR 03-21 17:11:14 [core.py:340] self.collective_rpc("init_device") ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/executor/uniproc_executor.py", line 56, in collective_rpc ERROR 03-21 17:11:14 [core.py:340] answer = run_method(self.driver_worker, method, args, kwargs) ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/utils.py", line 2216, in run_method ERROR 03-21 17:11:14 [core.py:340] return func(*args, **kwargs) ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^ ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/worker/worker_base.py", line 604, in init_device ERROR 03-21 17:11:14 [core.py:340] self.worker.init_device() # type: ignore ERROR 03-21 17:11:14 [core.py:340] ^^^^^^^^^^^^^^^^^^^^^^^^^ ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/worker/gpu_worker.py", line 103, in init_device ERROR 03-21 17:11:14 [core.py:340] torch.cuda.set_device(self.device) ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/torch/cuda/__init__.py", line 476, in set_device ERROR 03-21 17:11:14 [core.py:340] torch._C._cuda_setDevice(device) ERROR 03-21 17:11:14 [core.py:340] File "/root/anaconda3/lib/python3.12/site-packages/torch/cuda/__init__.py", line 305, in _lazy_init ERROR 03-21 17:11:14 [core.py:340] raise RuntimeError( ERROR 03-21 17:11:14 [core.py:340] RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method ERROR 03-21 17:11:14 [core.py:340] CRITICAL 03-21 17:11:14 [core_client.py:269] Got fatal signal from worker processes, shutting down. See stack trace above for root cause issue.If add
os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn" will get
INFO 03-21 19:05:49 [__init__.py:256] Automatically detected platform cuda. MODEL_PATH: /mnt/d/Users/Admin/.cache/modelscope/hub/qwen/Qwen2___5-Coder-0___5B-Instruct-AWQ INFO 03-21 19:07:27 [config.py:583] This model supports multiple tasks: {'embed', 'reward', 'score', 'generate', 'classify'}. Defaulting to 'generate'. INFO 03-21 19:07:27 [awq_marlin.py:114] The model is convertible to awq_marlin during runtime. Using awq_marlin kernel. INFO 03-21 19:07:27 [config.py:1693] Chunked prefill is enabled with max_num_batched_tokens=8192. WARNING 03-21 19:07:27 [cuda.py:95] To see benefits of async output processing, enable CUDA graph. Since, enforce-eager is enabled, async output processor cannot be used INFO 03-21 19:07:40 [__init__.py:256] Automatically detected platform cuda. MODEL_PATH: /mnt/d/Users/Admin/.cache/modelscope/hub/qwen/Qwen2___5-Coder-0___5B-Instruct-AWQ INFO 03-21 19:07:50 [config.py:583] This model supports multiple tasks: {'embed', 'reward', 'score', 'generate', 'classify'}. Defaulting to 'generate'. INFO 03-21 19:07:50 [awq_marlin.py:114] The model is convertible to awq_marlin during runtime. Using awq_marlin kernel. INFO 03-21 19:07:50 [config.py:1693] Chunked prefill is enabled with max_num_batched_tokens=8192. WARNING 03-21 19:07:50 [cuda.py:95] To see benefits of async output processing, enable CUDA graph. Since, enforce-eager is enabled, async output processor cannot be used Traceback (most recent call last): File "<string>", line 1, in <module> File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 122, in spawn_main exitcode = _main(fd, parent_sentinel) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 131, in _main prepare(preparation_data) File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 246, in prepare _fixup_main_from_path(data['init_main_from_path']) File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 297, in _fixup_main_from_path main_content = runpy.run_path(main_path, ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/runpy.py", line 287, in run_path return _run_module_code(code, init_globals, run_name, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/runpy.py", line 98, in _run_module_code _run_code(code, mod_globals, init_globals, File "/root/anaconda3/lib/python3.12/runpy.py", line 88, in _run_code exec(code, run_globals) File "/mnt/d/my/work/study/ai/kaggle_code/aimo2/vllm_test.py", line 17, in <module> llm = vllm.LLM( ^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/utils.py", line 1031, in inner return fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/entrypoints/llm.py", line 242, in __init__ self.llm_engine = LLMEngine.from_engine_args( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 137, in from_engine_args return cls(vllm_config=vllm_config, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/llm_engine.py", line 86, in __init__ self.engine_core = EngineCoreClient.make_client( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 66, in make_client return SyncMPClient(vllm_config, executor_class, log_stats) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 337, in __init__ super().__init__( File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/engine/core_client.py", line 301, in __init__ self.resources.proc_handle = BackgroundProcHandle( ^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/site-packages/vllm/v1/utils.py", line 121, in __init__ self.proc.start() File "/root/anaconda3/lib/python3.12/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) ^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/multiprocessing/context.py", line 289, in _Popen return Popen(process_obj) ^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 32, in __init__ super().__init__(process_obj) File "/root/anaconda3/lib/python3.12/multiprocessing/popen_fork.py", line 19, in __init__ self._launch(process_obj) File "/root/anaconda3/lib/python3.12/multiprocessing/popen_spawn_posix.py", line 42, in _launch prep_data = spawn.get_preparation_data(process_obj._name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 164, in get_preparation_data _check_not_importing_main() File "/root/anaconda3/lib/python3.12/multiprocessing/spawn.py", line 140, in _check_not_importing_main raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if __name__ == '__main__': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable. To fix this issue, refer to the "Safe importing of main module" section in https://docs.python.org/3/library/multiprocessing.htmlThen the program freezes.Unable to end.
using torch2.7.0 and vllm 0.9.0.1 When I use the pip install flash attn command to install the flash_attn-2.7.4.post1 library, the same situation occurs. It is OK to run before installation