Compatibility with pip-installed openmpi (#2741)
Some checks failed
Nightly Build / build_linux_release (3.10) (push) Has been cancelled
Nightly Build / build_linux_release (3.14) (push) Has been cancelled
Nightly Build / build_linux_with_tests (3.10) (push) Has been cancelled
Nightly Build / build_linux_with_tests (3.11) (push) Has been cancelled
Nightly Build / build_linux_with_tests (3.12) (push) Has been cancelled
Nightly Build / build_linux_with_tests (3.13) (push) Has been cancelled
Nightly Build / build_linux_with_tests (3.14) (push) Has been cancelled
Nightly Build / build_mac_release (3.10) (push) Has been cancelled
Nightly Build / build_mac_release (3.13) (push) Has been cancelled
Nightly Build / build_cuda_with_tests (push) Has been cancelled
Nightly Build / build_cuda_release (push) Has been cancelled
Nightly Build / Linux Fedora CPP Build (aarch64) (push) Has been cancelled
Nightly Build / Linux Fedora CPP Build (x86_64) (push) Has been cancelled

This commit is contained in:
Pedro Cuenca
2025-11-08 01:58:31 +01:00
committed by GitHub
parent be9e2aebd6
commit eba6a9d163
3 changed files with 52 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
// Copyright © 2024 Apple Inc.
#include <dlfcn.h>
#include <cstdlib>
#include <iostream>
#include "mlx/backend/cpu/encoder.h"
@@ -19,11 +20,17 @@
} \
}
static const char* get_libmpi_name() {
const char* libname = std::getenv("MLX_MPI_LIBNAME");
if (libname != nullptr) {
return libname;
}
#ifdef __APPLE__
static constexpr const char* libmpi_name = "libmpi.dylib";
return "libmpi.dylib";
#else
static constexpr const char* libmpi_name = "libmpi.so";
return "libmpi.so";
#endif
}
namespace mlx::core::distributed::mpi {
@@ -94,7 +101,7 @@ struct MPIWrapper {
MPIWrapper() {
initialized_ = false;
libmpi_handle_ = dlopen(libmpi_name, RTLD_NOW | RTLD_GLOBAL);
libmpi_handle_ = dlopen(get_libmpi_name(), RTLD_NOW | RTLD_GLOBAL);
if (libmpi_handle_ == nullptr) {
return;
}