mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 18:15:35 +08:00
Remove unused find_cuda_init helper script (#25044)
This commit is contained in:
parent
4aa8c7b047
commit
d6a518fdde
@ -1,36 +0,0 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
||||||
|
|
||||||
import importlib
|
|
||||||
import traceback
|
|
||||||
from typing import Callable
|
|
||||||
from unittest.mock import patch
|
|
||||||
|
|
||||||
|
|
||||||
def find_cuda_init(fn: Callable[[], object]) -> None:
|
|
||||||
"""
|
|
||||||
Helper function to debug CUDA re-initialization errors.
|
|
||||||
|
|
||||||
If `fn` initializes CUDA, prints the stack trace of how this happens.
|
|
||||||
"""
|
|
||||||
from torch.cuda import _lazy_init
|
|
||||||
|
|
||||||
stack = None
|
|
||||||
|
|
||||||
def wrapper():
|
|
||||||
nonlocal stack
|
|
||||||
stack = traceback.extract_stack()
|
|
||||||
return _lazy_init()
|
|
||||||
|
|
||||||
with patch("torch.cuda._lazy_init", wrapper):
|
|
||||||
fn()
|
|
||||||
|
|
||||||
if stack is not None:
|
|
||||||
print("==== CUDA Initialized ====")
|
|
||||||
print("".join(traceback.format_list(stack)).strip())
|
|
||||||
print("==========================")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
find_cuda_init(
|
|
||||||
lambda: importlib.import_module("vllm.model_executor.models.llava"))
|
|
||||||
Loading…
x
Reference in New Issue
Block a user