英文:
AttributeError: module 'os' has no attribute 'geteuid'
问题
When I run the code on Win11, it raises an error as follows:
AttributeError: module 'os' has no attribute 'geteuid'
I have found an answer on GitHub like this:
geteuid() is only available on Unix-like systems. This explains why it doesn't work on Windows.
So I want to know how to replace the os.getuid()
with others on Win11 or how can I get the --dist-url
?
英文:
when I run the code on Win11
# 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)
)
it raise error as follow
AttributeError: module 'os' has no attribute 'geteuid'
I have found an answer on github like this
geteuid() is only available on unix like systems. This explains why it doesn't work on Windows.
so I want to konw how to replace the os.getuid() with others on Win11,or how can I get the "--dist-url"?
答案1
得分: 0
我已解决了Win11上的这个问题。
if os.name == 'nt':
port = 2 ** 15 + 2 ** 14 + hash(getpass.getuser()) % 2 ** 14
在Windows上,我们可以使用getpass.getuser()。
英文:
I have solve this problems on win11
if os.name=='nt':
port = 2 ** 15 + 2 ** 14 + hash(getpass.getuser()) % 2 ** 14
we can use getpass.getuser() on Windows.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论