在Win 11上运行代码时
# PyTorch still may leave orphan processes in multi-gpu training.
# Therefore we use a deterministic way to obtain port,
# so that users are aware of orphan processes by seeing the port occupied.
port = 2 ** 15 + 2 ** 14 + hash(os.getuid()) % 2 ** 14
parser.add_argument(
"--dist-url", default="tcp://127.0.0.1:{}".format(port)
)
它会引发如下错误
AttributeError: module 'os' has no attribute 'geteuid'
我在github上找到了这样的答案
geteuid() is only available on unix like systems. This explains why it doesn't work on Windows.
所以我想知道如何在Win 11上将os.getuid()替换成其他的,或者如何获得"--dist-url”?
1条答案
按热度按时间pbpqsu0x1#
我已经在win11上解决了这个问题
我们可以在Windows上使用getpass.getuser()。