Skip to content

Search CUDA toolkit from python packages #2842

Closed

Description

@zcbenz

Currently mlx-cuda requires a system install of CUDA toolkit:

// Return the location of the CUDA toolkit.
const std::string& cuda_home() {
static std::string home = []() -> std::string {
const char* home = std::getenv("CUDA_HOME");
if (home) {
return home;
}
home = std::getenv("CUDA_PATH");
if (home) {
return home;
}
#if defined(__linux__)
home = "/usr/local/cuda";
if (std::filesystem::exists(home)) {
return home;
}
#endif
throw std::runtime_error(
"Environment variable CUDA_HOME or CUDA_PATH is not set.");
}();
return home;
}

It would be nice to be able to search from installed python packages as well so users can do:

uv run --with 'mlx[cuda]' --with 'cuda-toolkit[all]==12.9' python test_mlx.py

Activity

  1. leofang commented on Nov 27, 2025

    @leofang

    Hello from CUDA Python! 👋 The cuda-pathfinder package was designed for precisely this use case, and it has been adopted by CuPy, PyTorch, and many other Python CUDA packages!
    https://nvidia.github.io/cuda-python/cuda-pathfinder/latest/generated/cuda.pathfinder.load_nvidia_dynamic_lib.html
    Any issues can be reported to https://github.com/NVIDIA/cuda-python 🙂 Let us know how we can help you.

  2. zcbenz commented on Nov 27, 2025

    @zcbenz
    MemberAuthor

    @leofang This is super helpful, thanks a lot!

  3. self-assigned this
    on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions