cucim icon indicating copy to clipboard operation
cucim copied to clipboard

[FEA] Enable cuda-version dependency resolution for packages that depend on cucim or other rapids packages

Open thewtex opened this issue 11 months ago • 4 comments

Problem Statement

I want to create packages that depend on cuCIM or other RAPIDs packages. Through standard Python package dependencies, it would be very helpful to

  • Have a correct compatible version pulled in automatically without hardcoding a specific CUDA version when it is not needed directly
  • Conflicts, e.g. CUDA versions, are detected and an informative error provided

Example package installation with pip itkwasm-downsample-cucim.

Right now, all compatible CUDA dependencies and any other unrelated packages with CUDA dependencies need to be pre-installed explicitly by the user, who must know that they are installing compatible versions of everything (and their transitive dependencies are compatible). Or, a hard-coded cuda version is added as a dependency, which might conflict with other package dependencies.

A possible approach that might work (?) for pip, similar to the cuda-version used in conda, is to use the ability to have optional dependencies that are self-referential in the following way:

  1. cucim[cudefault] dependency depends on cucim[cu11], cucim[cu11] depends on cuda-version~=11, cupy[cu11]
  2. my-package-uses-cucim depends on cucim[cudefault]
  3. RAPIDs packages all periodically update [cudefault] dependencies on [cuXX] in harmony

cucim pyproject.toml:

[project]
name = "cucim"

[project.optional-dependencies]
cu11 = [
  "cucim-cu11",
  "cuda-version~=11",
]
cu12 = [
  "cucim-cu12",
  "cuda-version~=12",
]
cudefault = [
  "cucim[cu11]",
]

Where cuda-version is a meta-package used to identify dependency conflicts. Ideally cuda-version is in both in conda and pip so both dependency resolvers pick up conflicts.

my-package-uses-cucim pyproject.toml:

[project]
name = "my-package-uses-cucim"

dependencies = [
  "cucim[cudefault]"
]

thewtex avatar Mar 05 '24 22:03 thewtex