谢谢您阅读
从源代码运行时,出现“不支持的地址族”错误,因为方法“ _get_wildcard_address”返回的值为“ ::”
在tensorboard源代码中,我修改了program.py,打印了一些vars
program.py
def _get_wildcard_address(self, port):
"""Returns a wildcard address for the port in question.
This will attempt to follow the best practice of calling getaddrinfo() with
a null host and AI_PASSIVE to request a server-side socket wildcard address.
If that succeeds, this returns the first IPv6 address found, or if none,
then returns the first IPv4 address. If that fails, then this returns the
hardcoded address "::" if socket.has_ipv6 is True, else "0.0.0.0".
"""
print("port:", port)
fallback_address = '::' if socket.has_ipv6 else '0.0.0.0'
if hasattr(socket, 'AI_PASSIVE'):
try:
addrinfos = socket.getaddrinfo(None, port, socket.AF_UNSPEC,
socket.SOCK_STREAM, socket.IPPROTO_TCP,
socket.AI_PASSIVE)
print("addrinfos:", addrinfos)
except socket.gaierror as e:
logger.warn('Failed to auto-detect wildcard address, assuming %s: %s',
fallback_address, str(e))
return fallback_address
addrs_by_family = defaultdict(list)
for family, _, _, _, sockaddr in addrinfos:
# Format of the "sockaddr" socket address varies by address family,
# but [0] is always the IP address portion.
addrs_by_family[family].append(sockaddr[0])
print("addrs_by_family:", addrs_by_family)
print("socket.AF_INET6:", socket.AF_INET6)
print("socket.AF_INET:", socket.AF_INET)
if hasattr(socket, 'AF_INET6') and addrs_by_family[socket.AF_INET6]:
print("return INET6 addr:", addrs_by_family[socket.AF_INET6][0])
return addrs_by_family[socket.AF_INET6][0]
if hasattr(socket, 'AF_INET') and addrs_by_family[socket.AF_INET]:
print("return INET addr:", addrs_by_family[socket.AF_INET][0])
return addrs_by_family[socket.AF_INET][0]
logger.warn('Failed to auto-detect wildcard address, assuming %s',
fallback_address)
return fallback_address
运行命令得到了:
$ bazel run //tensorboard -- --logdir /home/admin/sean.xd/tmp/
INFO: Analysed target //tensorboard:tensorboard (0 packages loaded).
INFO: Found 1 target...
Target //tensorboard:tensorboard up-to-date:
bazel-bin/tensorboard/tensorboard
INFO: Elapsed time: 0.280s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
port: 6006
addrinfos: [(2, 1, 6, '', ('0.0.0.0', 6006)), (10, 1, 6, '', ('::', 6006, 0, 0))]
addrs_by_family: defaultdict(<type 'list'>, {2: ['0.0.0.0'], 10: ['::']})
socket.AF_INET6: 10
socket.AF_INET: 2
return INET6 addr: ::
host: ::
E1116 20:02:21.122143 MainThread program.py:201] Tensorboard could not bind to unsupported address family ::
WARNING: Logging before flag parsing goes to stderr.
E1116 20:02:21.122143 139781956085568 program.py:201] Tensorboard could not bind to unsupported address family ::
ERROR: Tensorboard could not bind to unsupported address family ::
生存:
$ uname -a
Linux arks7.inc.alipay.net 3.10.0-327.ali2000.alios7.x86_64#1 SMP Tue Dec 29 29:54:05 CST 2015 x86_64 x86_64 x86_64 GNU / Linux (xudong_test)
答案 0 :(得分:0)
最近,我遇到了类似的问题。 如果未找到解决方案,则可能需要看看https://groups.google.com/forum/#!topic/keras-users/CSKLSgCqjaM
答案 1 :(得分:0)
我通过添加“ --host”参数来解决此问题,即:
tensorboard --logdir ./ --port xxxx --host 0.0.0.0