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 17, 04:15 UTC
fix `get_ip` error in pure ipv6 environment (#2931)
Jingru committed
Feb 27, 2024 at 11:22 UTC
2410e320b35cd704059b7c6ba8d8ba7643fe46ee
1 file changed
+19
-5
vllm/utils.py
+19
-5
@@ -162,9 +162,16 @@ def make_async(func: Callable[..., T]) -> Callable[..., Awaitable[T]]:
162
163
164
def get_ip() -> str:
165
+ # try ipv4
166
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
166
- s.connect(("8.8.8.8", 80)) # Doesn't need to be reachable
167
- return s.getsockname()[0]
167
+ try:
168
+ s.connect(("dns.google", 80)) # Doesn't need to be reachable
169
+ return s.getsockname()[0]
170
+ except OSError:
171
+ # try ipv6
172
+ s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
173
+ s.connect(("dns.google", 80))
174
+ return s.getsockname()[0]
175
176
177
def get_distributed_init_method(ip: str, port: int) -> str:
@@ -172,9 +179,16 @@ def get_distributed_init_method(ip: str, port: int) -> str:
179
180
181
def get_open_port() -> int:
175
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
176
- s.bind(("", 0))
177
- return s.getsockname()[1]
182
+ # try ipv4
183
+ try:
184
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
185
+ s.bind(("", 0))
186
+ return s.getsockname()[1]
187
+ except OSError:
188
+ # try ipv6
189
+ with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
190
+ s.bind(("", 0))
191
+ return s.getsockname()[1]
192
193
194
def set_cuda_visible_devices(device_ids: List[int]) -> None: