Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cuda_root_path: Find cuda libraries when installed with conda packages #20288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions xla/tsl/platform/default/cuda_root_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ std::vector<std::string> CandidateCudaRoots() {
// Also add the path to the copy of libdevice.10.bc that we include within
// the Python wheel.
roots.emplace_back(io::JoinPath(dir, "cuda"));

// In case cuda was installed with nvidia's official conda packages, we also
// include the root prefix of the environment in the candidate roots dir,
// we assume that the lib binaries are either in the python package's root dir
// or in a 'python' subdirectory, as done by the previous for.
// python packages on non-Windows platforms are installed in
// $CONDA_PREFIX/lib/python3.12/site-packages/pkg_name, so if we want
// to add $CONDA_PREFIX to the candidate roots dirs we need to add
// ../../../..
for (auto path : {"../../../..", "../../../../.."})
roots.emplace_back(io::JoinPath(dir, path));
}
#endif // defined(PLATFORM_POSIX) && !defined(__APPLE__)

Expand Down