Skip to content

Commit 60e3f03

Browse files
libing0526libing0526
andauthored
fix(env): add cuda path and fix quote escaping (#7)
* docs: update name of latest installer exe in download section * fix(env): add CUDA path and fix quote escaping * fix(env): add cuda path and fix quote escaping --------- Co-authored-by: libing0526 <libqtweb@gmail.com>
1 parent e5923b9 commit 60e3f03

File tree

4 files changed

+28
-33
lines changed

4 files changed

+28
-33
lines changed

src/parallax/cli/commands/base_command.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ class WSLCommand : public BaseCommand<Derived> {
210210
command);
211211
}
212212

213+
// Build venv activation command with CUDA environment
214+
std::string BuildVenvActivationCommand(const CommandContext& context) {
215+
// Filter out Windows paths and add CUDA path
216+
// Use single quotes and careful escaping for PowerShell/CMD compatibility
217+
return "cd ~/parallax && "
218+
"export PATH=/usr/local/cuda-12.8/bin:$(echo '$PATH' | tr ':' '\\n' | grep -v '/mnt/c' | paste -sd ':' -) && "
219+
"source ./venv/bin/activate";
220+
}
221+
213222
// Escape arguments for safe passing through bash -c "..."
214223
// This prevents command injection and correctly handles spaces/special chars
215224
// Note: This is for WSL bash layer, not Windows PowerShell layer

src/parallax/cli/commands/cmd_command.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,22 @@ std::string CmdCommand::BuildCommand(const CommandContext& context,
130130
std::string full_command;
131131

132132
if (options.use_venv) {
133-
// Execute in virtual environment
134-
full_command = "cd ~/parallax && source ./venv/bin/activate";
133+
// Execute in virtual environment with CUDA PATH
134+
full_command = BuildVenvActivationCommand(context);
135135

136136
// Add proxy support (similar to implementation in model_commands.cpp)
137137
if (!context.proxy_url.empty()) {
138-
full_command += " && HTTP_PROXY=\"" + context.proxy_url +
139-
"\" HTTPS_PROXY=\"" + context.proxy_url + "\" " +
138+
full_command += " && HTTP_PROXY='" + context.proxy_url +
139+
"' HTTPS_PROXY='" + context.proxy_url + "' " +
140140
command;
141141
} else {
142142
full_command += " && " + command;
143143
}
144144
} else {
145145
// Execute directly in WSL
146146
if (!context.proxy_url.empty()) {
147-
full_command = "HTTP_PROXY=\"" + context.proxy_url +
148-
"\" HTTPS_PROXY=\"" + context.proxy_url + "\" " +
147+
full_command = "HTTP_PROXY='" + context.proxy_url +
148+
"' HTTPS_PROXY='" + context.proxy_url + "' " +
149149
command;
150150
} else {
151151
full_command = command;

src/parallax/cli/commands/model_commands.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ bool ModelRunCommand::RunParallaxScript(const CommandContext& context) {
4040
// Build run command: parallax run [user parameters...]
4141
std::string run_command = BuildRunCommand(context);
4242

43-
// Build complete WSL command: cd ~/parallax && source ./venv/bin/activate
44-
// && parallax run [args...]
45-
std::string full_command = "cd ~/parallax && source ./venv/bin/activate";
43+
// Build complete WSL command with venv activation and CUDA environment
44+
std::string full_command = BuildVenvActivationCommand(context);
4645

4746
// If proxy is configured, add proxy environment variables
4847
if (!context.proxy_url.empty()) {
49-
full_command += " && HTTP_PROXY=\"" + context.proxy_url +
50-
"\" HTTPS_PROXY=\"" + context.proxy_url + "\" " +
48+
full_command += " && HTTP_PROXY='" + context.proxy_url +
49+
"' HTTPS_PROXY='" + context.proxy_url + "' " +
5150
run_command;
5251
} else {
5352
full_command += " && " + run_command;
@@ -95,14 +94,13 @@ CommandResult ModelJoinCommand::ExecuteImpl(const CommandContext& context) {
9594
// Build cluster join command: parallax join [user parameters...]
9695
std::string join_command = BuildJoinCommand(context);
9796

98-
// Build complete WSL command: cd ~/parallax && source ./venv/bin/activate
99-
// && parallax join [args...]
100-
std::string full_command = "cd ~/parallax && source ./venv/bin/activate";
97+
// Build complete WSL command with venv activation and CUDA environment
98+
std::string full_command = BuildVenvActivationCommand(context);
10199

102100
// If proxy is configured, add proxy environment variables
103101
if (!context.proxy_url.empty()) {
104-
full_command += " && HTTP_PROXY=\"" + context.proxy_url +
105-
"\" HTTPS_PROXY=\"" + context.proxy_url + "\" " +
102+
full_command += " && HTTP_PROXY='" + context.proxy_url +
103+
"' HTTPS_PROXY='" + context.proxy_url + "' " +
106104
join_command;
107105
} else {
108106
full_command += " && " + join_command;

src/parallax/environment/software_installer2.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -257,23 +257,11 @@ ComponentResult ParallaxProjectInstaller::Install() {
257257
true);
258258

259259
if (!is_update_mode) {
260-
// Only install sgl_kernel during first installation (use real-time
261-
// output)
262-
std::string install_sgl_cmd =
263-
"cd ~/parallax && source ./venv/bin/activate && pip install "
264-
"https://github.com/sgl-project/whl/releases/download/v0.3.7/"
265-
"sgl_kernel-0.3.7+cu128-cp310-abi3-manylinux2014_x86_64.whl "
266-
"--force-reinstall";
267-
if (!proxy_url.empty()) {
268-
install_sgl_cmd =
269-
"cd ~/parallax && source ./venv/bin/activate && HTTP_PROXY=\"" +
270-
proxy_url + "\" HTTPS_PROXY=\"" + proxy_url +
271-
"\" pip install "
272-
" https://github.com/sgl-project/whl/releases/download/v0.3.7/"
273-
"sgl_kernel-0.3.7+cu128-cp310-abi3-manylinux2014_x86_64.whl "
274-
"--force-reinstall";
275-
}
276-
commands.emplace_back("install_sgl_kernel", install_sgl_cmd, 600, true);
260+
// Add CUDA environment variable to system profile (only during first installation)
261+
std::string add_cuda_env_cmd =
262+
"grep -q '/usr/local/cuda-12.8/bin' ~/.bashrc || "
263+
"echo 'export PATH=/usr/local/cuda-12.8/bin:$PATH' >> ~/.bashrc";
264+
commands.emplace_back("add_cuda_env", add_cuda_env_cmd, 30, false);
277265
}
278266

279267
// Execute command sequence

0 commit comments

Comments
 (0)