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

EPIC: Path finder for CUDA components #451

Open
leofang opened this issue Feb 14, 2025 · 5 comments
Open

EPIC: Path finder for CUDA components #451

leofang opened this issue Feb 14, 2025 · 5 comments
Assignees
Labels
cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module EPIC Soul of a release feature New feature or request P1 Medium priority - Should do

Comments

@leofang
Copy link
Member

leofang commented Feb 14, 2025

In 2025, there are many ways of installing CUDA to a Python environment. One key challenge here is that all header/library search logics implemented in the existing CUDA-enabled libraries (ex: #447) need to be modernized, taking into account that CUDA these days can be installed on a per-component basis (ex: I just want NVRTC and CCCL and nothing else). The consequence is that any prior arts that rely on checking if a certain piece exists (ex: nvcc, cuda.h, nvvm, ...) and generalizing it to assume the whole Toolkit exists based on known relative paths are no longer valid. Even Linux system package managers may not always behave as expected. (Though setting CUDA_HOME/CUDA_PATH as a fallback might still be OK.)

The CUDA Python team is well-positioned to take on the pain points so that all other Python libraries do not need to worry about packaging sources, layouts, and so on. It is our intention to support modern CUDA packages and deployment options in a JIT-compilation friendly way. What this means is that we should be able to return, on a per-component basis,

  • where are the component headers?
  • where are the component shared libraries?
  • ...

Something like (API design TBD)

from cuda.core.utils import CUDALocater

locater = CUDALocater()
nvcc_incl = locater.nvcc.include  # returns a list of valid abs paths to the include directories, or None 
cccl_incl = locater.cccl.include  # returns a list of valid abs paths to the include directories, or None
nvrtc_lib = locater.nvrtc.lib     # returns a list of valid abs paths to the shared libraries, or None 
...

This needs to cover

  • CUDA installed via various package managers (apt, yum, conda, pip, ...)
  • Headers and shared libraries as bare minimum
    • From JIT compilation perspective, headers are considered a kind of shared libraries
  • Linux and Windows
  • Default system search paths, if possible
    • This includes the "legacy" CTK locations, such as /usr/local/cuda on Linux, as a fallback
  • All CTK components relevant to Python users, such as:
    • nvcc/nvvm
      • this includes libdevice.bc
    • nvrtc
    • nvjitlink
    • cublas
    • cusolver
    • curand
    • cufft
    • cusparse
    • ...

Once completed, this would also help us unify the treatment of loading shared libraries in cuda.bindings, which is currently divergent between Linux/Windows:

  • Linux: hack RPATH and rely on dynamic loader (ld.so)
  • Windows: search possible DLL locations (site-packages, ...)
@github-actions github-actions bot added the triage Needs the team's attention label Feb 14, 2025
@leofang
Copy link
Member Author

leofang commented Feb 14, 2025

cc @rwgk

@leofang leofang added feature New feature or request cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module EPIC Soul of a release labels Feb 14, 2025
@leofang leofang changed the title Path finder for CUDA components EPIC: Path finder for CUDA components Feb 14, 2025
@leofang
Copy link
Member Author

leofang commented Feb 18, 2025

I expect our path finder is enough for these projects to drop the following code

@leofang leofang added P1 Medium priority - Should do and removed triage Needs the team's attention labels Feb 18, 2025
@leofang
Copy link
Member Author

leofang commented Feb 18, 2025

Another question we need to answer is: In which module (binding or core) should we place the path finder? This seems like a high-level pythonic helper that is suitable for cuda.core, but cuda.bindings would need the same info for loading modules if we pull this off. I don't have an answer.

@leofang
Copy link
Member Author

leofang commented Feb 18, 2025

(discussed offline, tentatively slate this for beta 3, with the understanding that we might not make it)

@leofang leofang added this to the cuda.core beta 3 milestone Feb 18, 2025
@leofang
Copy link
Member Author

leofang commented Feb 19, 2025

cc @cryos for vis (since you're also working on wheels)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module EPIC Soul of a release feature New feature or request P1 Medium priority - Should do
Projects
None yet
Development

No branches or pull requests

2 participants