NVIDIA / cuda-python

CUDA Python Low-level Bindings
https://nvidia.github.io/cuda-python/
Other
809 stars 63 forks source link

cuda-python conda packages should avoid depending on the entire CUDA Toolkit #43

Closed bdice closed 1 year ago

bdice commented 1 year ago

Conda packages released for cuda-python to the nvidia channel depend on cuda-toolkit, i.e. the entire CUDA Toolkit.

https://anaconda.org/nvidia/cuda-python/files?version=12.0.0

The cuda-python package should declare dependencies only on components that are actually used, which might be a more limited subset like these, which I found by reading extern from declarations:

jakirkham commented 1 year ago

Would the cuda-cudart package be sufficient? Or is more needed than that?

bdice commented 1 year ago

@jakirkham I think building the package requires CUDA headers (so -dev packages for cuda-cudart-dev and cuda-nvrtc-dev). At runtime, perhaps only cuda-cudart and cuda-nvrtc are needed?

The features depending on cudaProfiler.h are not brought in as a dependency of cuda-cudart and thus must be explicitly depended on via cuda-profiler-api at build time.

leofang commented 1 year ago

cuda-cudart is not needed at runtime, as currently the cudart layer in CUDA Python is a reimplementation of cudart. So just NVRTC.

jakirkham commented 1 year ago

Thanks all! That sounds reasonable. Let's see if @vzhurba01 & @m3vaz have more thoughts 🙂

vzhurba01 commented 1 year ago

As pointed out, building the package requires CUDA headers. The headers parsed are: https://github.com/NVIDIA/cuda-python/blob/9ac2d31eaf5ba5aee3ff4a0b70df0dc81ccf83fb/setup.py#L37

For building, the headers can be categorized into 3 groups:

  1. Required to build
  2. Optional to enable features
  3. Always enabled

(1) Referenced by extern from, list by @bdice looks complete (2) Not used right now (3) cuda_profiler_api.h and graphics APIs (EGL, GL, VDPAU)

For runtime, the requirements are:

  1. NVRTC is needed if you use NVRTC
  2. CUDART is needed if you build kernels referencing some CUDART types

(2) Many types are built-in though, but not all. One of the ported examples/samples encounter such a scenario.

Perhaps (2) can be limited to only the built-in types, and remaining dependency if needed can be added by users?

bdice commented 1 year ago

I would be happy to keep cudart and nvrtc as “hard” runtime dependencies to ensure the package is fully functional. The main parts I want to strip out are the rest of cuda-toolkit that make it very large, like math libraries.

How should we go about making this change? The conda-forge side can simply use this dependency list. We’ll want to reflect the same set of dependencies for the nvidia channel version and issue a new version (or a new build of the same version).

vzhurba01 commented 1 year ago

Release v12.1.0 trims Conda dependencies to only require NVRTC and CUDART (excluding math libraries). Closing.

jakirkham commented 1 year ago

Thanks Vlad! 🙏