A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 16, 18:15 UTC
[ci] try to log process using the port to debug the port usage (#7711)
youkaichao committed
Aug 20, 2024 at 17:41 UTC
b74a12580022039fc15fb54c7066cc13fdc96220
2 files changed
+17
vllm/entrypoints/launcher.py
+7
@@ -10,6 +10,7 @@ from vllm import envs
10
from vllm.engine.async_llm_engine import AsyncEngineDeadError
11
from vllm.engine.protocol import AsyncEngineClient
12
from vllm.logger import init_logger
13
+from vllm.utils import find_process_using_port
14
15
logger = init_logger(__name__)
16
@@ -48,6 +49,12 @@ async def serve_http(app: FastAPI, engine: AsyncEngineClient,
49
await server_task
50
return dummy_shutdown()
51
except asyncio.CancelledError:
52
+ port = uvicorn_kwargs["port"]
53
+ process = find_process_using_port(port)
54
+ if process is not None:
55
+ logger.debug(
56
+ "port %s is used by process %s launched with command:\n%s",
57
+ port, process, " ".join(process.cmdline()))
58
logger.info("Gracefully stopping http server")
59
return server.shutdown()
60
vllm/utils.py
+10
@@ -547,6 +547,16 @@ def get_open_port() -> int:
547
return s.getsockname()[1]
548
549
550
+def find_process_using_port(port: int) -> Optional[psutil.Process]:
551
+ for conn in psutil.net_connections():
552
+ if conn.laddr.port == port:
553
+ try:
554
+ return psutil.Process(conn.pid)
555
+ except psutil.NoSuchProcess:
556
+ return None
557
+ return None
558
+
559
+
560
def update_environment_variables(envs: Dict[str, str]):
561
for k, v in envs.items():
562
if k in os.environ and os.environ[k] != v: