From 14d929936065fae2ebd99bc5d4ab32d8de7db11e Mon Sep 17 00:00:00 2001 From: Frank Lee Date: Thu, 12 Jan 2023 14:52:09 +0800 Subject: [PATCH] [cli] fixed hostname mismatch error (#2465) --- colossalai/cli/launcher/hostinfo.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/colossalai/cli/launcher/hostinfo.py b/colossalai/cli/launcher/hostinfo.py index 2f0830c58..065cbc371 100644 --- a/colossalai/cli/launcher/hostinfo.py +++ b/colossalai/cli/launcher/hostinfo.py @@ -1,5 +1,5 @@ -from typing import List import socket +from typing import List class HostInfo: @@ -35,9 +35,14 @@ class HostInfo: 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)