Skip to content

Commit c9cf54e

Browse files
authored
[runner] Drop buildLDLibraryPathEnv() (#3593)
This code is: - conda-specific - dead Basically, the function (ab)uses python3-config [1] utility (which, BTW, is not present in dstack base images since conda -> uv migration) to calculate the path to conda-installed shared objects and export it via LD_LIBRARY_PATH (the proper way to add conda-installed libs would be to use ld.so's configuration files, that is, ld.so.conf.d/*). Although this code was added in #1354, it is not related to TPU support at all. [1]: https://manpages.debian.org/testing/python3-dev/python3-config.1.en.html
1 parent be7daeb commit c9cf54e

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

runner/internal/executor/executor.go

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,6 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error
444444
"DSTACK_MPI_HOSTFILE": mpiHostfilePath,
445445
}
446446

447-
// Call buildLDLibraryPathEnv and update jobEnvs if no error occurs
448-
newLDPath, err := buildLDLibraryPathEnv(ctx)
449-
if err != nil {
450-
log.Info(ctx, "Continuing without updating LD_LIBRARY_PATH")
451-
} else {
452-
jobEnvs["LD_LIBRARY_PATH"] = newLDPath
453-
log.Info(ctx, "New LD_LIBRARY_PATH set", "LD_LIBRARY_PATH", newLDPath)
454-
}
455-
456447
cmd := exec.CommandContext(ctx, ex.jobSpec.Commands[0], ex.jobSpec.Commands[1:]...)
457448
cmd.Cancel = func() error {
458449
// returns error on Windows
@@ -504,8 +495,7 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error
504495
log.Warning(ctx, "failed to include dstack_profile", "path", profilePath, "err", err)
505496
}
506497

507-
err = writeMpiHostfile(ctx, ex.clusterInfo.JobIPs, gpusPerNodeNum, mpiHostfilePath)
508-
if err != nil {
498+
if err := writeMpiHostfile(ctx, ex.clusterInfo.JobIPs, gpusPerNodeNum, mpiHostfilePath); err != nil {
509499
return fmt.Errorf("write MPI hostfile: %w", err)
510500
}
511501

@@ -621,40 +611,6 @@ func isPtyError(err error) bool {
621611
return errors.As(err, &e) && errors.Is(e.Err, syscall.EIO)
622612
}
623613

624-
func buildLDLibraryPathEnv(ctx context.Context) (string, error) {
625-
// Execute shell command to get Python prefix
626-
cmd := exec.CommandContext(ctx, "bash", "-i", "-c", "python3-config --prefix")
627-
output, err := cmd.Output()
628-
if err != nil {
629-
return "", fmt.Errorf("error executing command: %w", err)
630-
}
631-
632-
// Extract and trim the prefix path
633-
prefixPath := strings.TrimSpace(string(output))
634-
635-
// Check if the prefix path exists
636-
if _, err := os.Stat(prefixPath); os.IsNotExist(err) {
637-
return "", fmt.Errorf("python prefix path does not exist: %s", prefixPath)
638-
}
639-
640-
// Construct the path to Python's shared libraries
641-
sharedLibPath := fmt.Sprintf("%s/lib", prefixPath)
642-
643-
// Get current LD_LIBRARY_PATH
644-
currentLDPath := os.Getenv("LD_LIBRARY_PATH")
645-
646-
// Append Python's shared library path if not already present
647-
if !strings.Contains(currentLDPath, sharedLibPath) {
648-
if currentLDPath == "" {
649-
currentLDPath = sharedLibPath
650-
} else {
651-
currentLDPath = fmt.Sprintf("%s:%s", currentLDPath, sharedLibPath)
652-
}
653-
}
654-
655-
return currentLDPath, nil
656-
}
657-
658614
// A simplified copypasta of creack/pty Start->StartWithSize->StartWithAttrs
659615
// with two additions:
660616
// * controlling terminal is properly set (cmd.Extrafiles, Cmd.SysProcAttr.Ctty)

0 commit comments

Comments
 (0)