Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
norm
vllm
Commits
b7984a7e
Commit
b7984a7e
authored
May 22, 2024
by
zhuwenwen
Browse files
fix socker error
parent
89683b9e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
vllm/utils.py
vllm/utils.py
+26
-6
No files found.
vllm/utils.py
View file @
b7984a7e
...
@@ -6,6 +6,7 @@ import uuid
...
@@ -6,6 +6,7 @@ import uuid
from
platform
import
uname
from
platform
import
uname
from
typing
import
List
,
Tuple
,
Union
from
typing
import
List
,
Tuple
,
Union
from
packaging.version
import
parse
,
Version
from
packaging.version
import
parse
,
Version
import
warnings
import
psutil
import
psutil
import
torch
import
torch
...
@@ -170,16 +171,35 @@ def make_async(func: Callable[..., T]) -> Callable[..., Awaitable[T]]:
...
@@ -170,16 +171,35 @@ def make_async(func: Callable[..., T]) -> Callable[..., Awaitable[T]]:
def
get_ip
()
->
str
:
def
get_ip
()
->
str
:
host_ip
=
os
.
environ
.
get
(
"HOST_IP"
)
if
host_ip
:
return
host_ip
# IP is not set, try to get it from the network interface
# try ipv4
# try ipv4
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
try
:
try
:
s
.
connect
((
"
dns.google
"
,
80
))
# Doesn't need to be reachable
s
.
connect
((
"
8.8.8.8
"
,
80
))
# Doesn't need to be reachable
return
s
.
getsockname
()[
0
]
return
s
.
getsockname
()[
0
]
except
OSError
:
except
Exception
:
pass
# try ipv6
# try ipv6
try
:
s
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
s
=
socket
.
socket
(
socket
.
AF_INET6
,
socket
.
SOCK_DGRAM
)
s
.
connect
((
"dns.google"
,
80
))
# Google's public DNS server, see
# https://developers.google.com/speed/public-dns/docs/using#addresses
s
.
connect
((
"2001:4860:4860::8888"
,
80
))
# Doesn't need to be reachable
return
s
.
getsockname
()[
0
]
return
s
.
getsockname
()[
0
]
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 HOST_IP."
,
stacklevel
=
2
)
return
"0.0.0.0"
def
get_distributed_init_method
(
ip
:
str
,
port
:
int
)
->
str
:
def
get_distributed_init_method
(
ip
:
str
,
port
:
int
)
->
str
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment