From 5f4013f770a718162d4590adda847dc5c6bc42b8 Mon Sep 17 00:00:00 2001 From: Dmitry Meyer Date: Thu, 19 Feb 2026 12:51:56 +0000 Subject: [PATCH] [runner] Drop buildLDLibraryPathEnv() This code: - is conda-specific - is dead - overwrites user/image-defined LD_LIBRARY_PATH in rare cases when it works 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 https://github.com/dstackai/dstack/pull/1354, it is not related to TPU support at all. [1]: https://manpages.debian.org/testing/python3-dev/python3-config.1.en.html --- runner/internal/executor/executor.go | 46 +--------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/runner/internal/executor/executor.go b/runner/internal/executor/executor.go index 85a59408f..61e18ee3e 100644 --- a/runner/internal/executor/executor.go +++ b/runner/internal/executor/executor.go @@ -444,15 +444,6 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error "DSTACK_MPI_HOSTFILE": mpiHostfilePath, } - // Call buildLDLibraryPathEnv and update jobEnvs if no error occurs - newLDPath, err := buildLDLibraryPathEnv(ctx) - if err != nil { - log.Info(ctx, "Continuing without updating LD_LIBRARY_PATH") - } else { - jobEnvs["LD_LIBRARY_PATH"] = newLDPath - log.Info(ctx, "New LD_LIBRARY_PATH set", "LD_LIBRARY_PATH", newLDPath) - } - cmd := exec.CommandContext(ctx, ex.jobSpec.Commands[0], ex.jobSpec.Commands[1:]...) cmd.Cancel = func() error { // returns error on Windows @@ -504,8 +495,7 @@ func (ex *RunExecutor) execJob(ctx context.Context, jobLogFile io.Writer) error log.Warning(ctx, "failed to include dstack_profile", "path", profilePath, "err", err) } - err = writeMpiHostfile(ctx, ex.clusterInfo.JobIPs, gpusPerNodeNum, mpiHostfilePath) - if err != nil { + if err := writeMpiHostfile(ctx, ex.clusterInfo.JobIPs, gpusPerNodeNum, mpiHostfilePath); err != nil { return fmt.Errorf("write MPI hostfile: %w", err) } @@ -621,40 +611,6 @@ func isPtyError(err error) bool { return errors.As(err, &e) && errors.Is(e.Err, syscall.EIO) } -func buildLDLibraryPathEnv(ctx context.Context) (string, error) { - // Execute shell command to get Python prefix - cmd := exec.CommandContext(ctx, "bash", "-i", "-c", "python3-config --prefix") - output, err := cmd.Output() - if err != nil { - return "", fmt.Errorf("error executing command: %w", err) - } - - // Extract and trim the prefix path - prefixPath := strings.TrimSpace(string(output)) - - // Check if the prefix path exists - if _, err := os.Stat(prefixPath); os.IsNotExist(err) { - return "", fmt.Errorf("python prefix path does not exist: %s", prefixPath) - } - - // Construct the path to Python's shared libraries - sharedLibPath := fmt.Sprintf("%s/lib", prefixPath) - - // Get current LD_LIBRARY_PATH - currentLDPath := os.Getenv("LD_LIBRARY_PATH") - - // Append Python's shared library path if not already present - if !strings.Contains(currentLDPath, sharedLibPath) { - if currentLDPath == "" { - currentLDPath = sharedLibPath - } else { - currentLDPath = fmt.Sprintf("%s:%s", currentLDPath, sharedLibPath) - } - } - - return currentLDPath, nil -} - // A simplified copypasta of creack/pty Start->StartWithSize->StartWithAttrs // with two additions: // * controlling terminal is properly set (cmd.Extrafiles, Cmd.SysProcAttr.Ctty)