Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions colossalai/cli/launcher/hostinfo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List
import socket
from typing import List


class HostInfo:
Expand Down Expand Up @@ -35,9 +35,14 @@ def is_host_localhost(hostname: str, port: str = None) -> None:

if port is None:
port = 22 # no port specified, lets just use the ssh port
hostname = socket.getfqdn(hostname)

# socket.getfqdn("127.0.0.1") does not return localhost
# on some users' machines
# thus, we directly return True if hostname is locahost, 127.0.0.1 or 0.0.0.0
if hostname in ("localhost", "127.0.0.1", "0.0.0.0"):
return True

hostname = socket.getfqdn(hostname)
localhost = socket.gethostname()
localaddrs = socket.getaddrinfo(localhost, port)
targetaddrs = socket.getaddrinfo(hostname, port)
Expand Down