Skip to content

Commit 5f2770d

Browse files
Merge branch 'vllm-project:main' into main
2 parents 5a9a351 + 943e72c commit 5f2770d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

vllm/envs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
if TYPE_CHECKING:
55
VLLM_HOST_IP: str = ""
6+
VLLM_PORT: Optional[int] = None
67
VLLM_USE_MODELSCOPE: bool = False
78
VLLM_INSTANCE_ID: Optional[str] = None
89
VLLM_NCCL_SO_PATH: Optional[str] = None
@@ -96,6 +97,12 @@
9697
'VLLM_HOST_IP':
9798
lambda: os.getenv('VLLM_HOST_IP', "") or os.getenv("HOST_IP", ""),
9899

100+
# used in distributed environment to manually set the communication port
101+
# '0' is used to make mypy happy
102+
'VLLM_PORT':
103+
lambda: int(os.getenv('VLLM_PORT', '0'))
104+
if 'VLLM_PORT' in os.environ else None,
105+
99106
# If true, will load models from ModelScope instead of Hugging Face Hub.
100107
# note that the value is true or false, not numbers
101108
"VLLM_USE_MODELSCOPE":

vllm/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ def get_distributed_init_method(ip: str, port: int) -> str:
282282

283283

284284
def get_open_port() -> int:
285+
port = envs.VLLM_PORT
286+
if port is not None:
287+
return port
285288
# try ipv4
286289
try:
287290
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:

0 commit comments

Comments
 (0)