Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change path to python for Windows os #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion trainer/distribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import subprocess
import time
import sys

from trainer import TrainerArgs, logger

Expand Down Expand Up @@ -51,7 +52,10 @@ def distribute():
command[-1] = f"--rank={rank}"
# prevent stdout for processes with rank != 0
stdout = None
p = subprocess.Popen(["python3"] + command, stdout=stdout, env=my_env) # pylint: disable=consider-using-with
if sys.platform == 'win32':
p = subprocess.Popen(["python"] + command, stdout=stdout, env=my_env) # pylint: disable=consider-using-with
else:
p = subprocess.Popen(["python3"] + command, stdout=stdout, env=my_env) # pylint: disable=consider-using-with
Comment on lines +55 to +58
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct, platform-and-virtualenv-agnostic way to do this is sys.executable.

Suggested change
if sys.platform == 'win32':
p = subprocess.Popen(["python"] + command, stdout=stdout, env=my_env) # pylint: disable=consider-using-with
else:
p = subprocess.Popen(["python3"] + command, stdout=stdout, env=my_env) # pylint: disable=consider-using-with
p = subprocess.Popen([sys.executable, *command], stdout=stdout, env=my_env) # pylint: disable=consider-using-with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we don't need to run this if it is not Win32.

processes.append(p)
logger.info(command)

Expand Down