Skip to content

Commit

Permalink
Fix wrong host problem
Browse files Browse the repository at this point in the history
Signed-off-by: Yuhong Guo <[email protected]>
  • Loading branch information
guoyuhong committed Nov 20, 2024
1 parent 63f1fde commit 3852b43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
9 changes: 8 additions & 1 deletion vllm/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

if TYPE_CHECKING:
VLLM_HOST_IP: str = ""
HOST_IP: str = ""
VLLM_PORT: Optional[int] = None
VLLM_RPC_BASE_PATH: str = tempfile.gettempdir()
VLLM_USE_MODELSCOPE: bool = False
Expand Down Expand Up @@ -153,7 +154,13 @@ def get_default_config_root():
# If you are using multi-node inference, you should set this differently
# on each node.
'VLLM_HOST_IP':
lambda: os.getenv('VLLM_HOST_IP', "") or os.getenv("HOST_IP", ""),
lambda: os.getenv('VLLM_HOST_IP', ""),

# used in distributed environment to determine the ip address
# of the current node, when the env variable VLLM_HOST_IP is not set
# and the it's hard to get the host ip.
'HOST_IP':
lambda: os.getenv('HOST_IP', ""),

# used in distributed environment to manually set the communication port
# Note: if VLLM_PORT is set, and some code asks for multiple ports, the
Expand Down
20 changes: 14 additions & 6 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ def get_ip() -> str:
except Exception:
pass

try:
return socket.gethostbyname(socket.gethostname())
except Exception:
pass

# try ipv6
try:
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
Expand All @@ -489,12 +494,15 @@ def get_ip() -> str:
except Exception:
pass

warnings.warn(
"Failed to get the IP address, using 0.0.0.0 by default."
"The value can be set by the environment variable"
" VLLM_HOST_IP or HOST_IP.",
stacklevel=2)
return "0.0.0.0"
if envs.HOST_IP:
return envs.HOST_IP
else:
warnings.warn(
"Failed to get the IP address, using 0.0.0.0 by default."
"The value can be set by the environment variable"
" VLLM_HOST_IP or HOST_IP.",
stacklevel=2)
return "0.0.0.0"


def is_valid_ipv6_address(address: str) -> bool:
Expand Down

0 comments on commit 3852b43

Please sign in to comment.