@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / fa839565f2
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 01:00 UTC

[Misc] Refactor: Improve argument handling for `conda` command (#20481)

Signed-off-by: reidliu41 <reid201711@gmail.com>

Reid committed Jul 16, 2025 at 10:43 UTC fa839565f2eb2f94d2a74c83993f3cfcacb4689a
1 file changed +25 -20
vllm/collect_env.py
+25 -20
@@ -96,25 +96,30 @@ DEFAULT_PIP_PATTERNS = {
96 def run(command):
97 """Return (return-code, stdout, stderr)."""
98 shell = True if type(command) is str else False
99 - p = subprocess.Popen(command,
100 - stdout=subprocess.PIPE,
101 - stderr=subprocess.PIPE,
102 - shell=shell)
103 - raw_output, raw_err = p.communicate()
104 - rc = p.returncode
105 - if get_platform() == 'win32':
106 - enc = 'oem'
107 - else:
108 - enc = locale.getpreferredencoding()
109 - output = raw_output.decode(enc)
110 - if command == 'nvidia-smi topo -m':
111 - # don't remove the leading whitespace of `nvidia-smi topo -m`
112 - # because they are meaningful
113 - output = output.rstrip()
114 - else:
115 - output = output.strip()
116 - err = raw_err.decode(enc)
117 - return rc, output, err.strip()
99 + try:
100 + p = subprocess.Popen(command,
101 + stdout=subprocess.PIPE,
102 + stderr=subprocess.PIPE,
103 + shell=shell)
104 + raw_output, raw_err = p.communicate()
105 + rc = p.returncode
106 + if get_platform() == 'win32':
107 + enc = 'oem'
108 + else:
109 + enc = locale.getpreferredencoding()
110 + output = raw_output.decode(enc)
111 + if command == 'nvidia-smi topo -m':
112 + # don't remove the leading whitespace of `nvidia-smi topo -m`
113 + # because they are meaningful
114 + output = output.rstrip()
115 + else:
116 + output = output.strip()
117 + err = raw_err.decode(enc)
118 + return rc, output, err.strip()
119 +
120 + except FileNotFoundError:
121 + cmd_str = command if isinstance(command, str) else command[0]
122 + return 127, '', f"Command not found: {cmd_str}"
123
124
125 def run_and_read_all(run_lambda, command):
@@ -148,7 +153,7 @@ def get_conda_packages(run_lambda, patterns=None):
153 if patterns is None:
154 patterns = DEFAULT_CONDA_PATTERNS
155 conda = os.environ.get('CONDA_EXE', 'conda')
151 - out = run_and_read_all(run_lambda, "{} list".format(conda))
156 + out = run_and_read_all(run_lambda, [conda, 'list'])
157 if out is None:
158 return out
159