fix(deps): preload cusolver if cupy is installed#1117
Conversation
jameslamb
left a comment
There was a problem hiding this comment.
Left a blocking suggestion.
If we end up using Python code to pre-load cusolver after you consider this feedback then I think that's ok and I think where you chose is the right place.
But some other thoughts...
- if some DSO in
cucimneedslibcusolver.so.*at runtime, why isn'tauditwheeltrying to vendor it? Or IS it making a copy? Worth checking, because I don't see it excluded here and would expect to:
Line 67 in 5c68f29
- I don't think we need a
cuda-pathfinderdependency. Could you look into just adding RPATH entries intosite-packages/, like we do for RAFT'scusolverdependency?
Normally when I jump into one of these packaging-codeowners reviewers where I wasn't assigned I remove the auto-assigned person, but leaving @KyleFromNVIDIA here because I think his thoughts on this topic would also be really helpful and possibly different from mine.
| - output_types: [requirements, pyproject] | ||
| packages: | ||
| - cuda-toolkit[cusolver] | ||
| - cuda-pathfinder |
There was a problem hiding this comment.
As written, this would allow cucim-cu13 to be installed with cuda-toolkit==12.*. I don't think we want that.. We won't catch that in CI because we == pin cuda-toolkit as an additional constraint:
Lines 185 to 204 in 5c68f29
... but that's a CI only thing.
We should ensure the wheel metadata provides a correct solve for users (CUDA 12 for -cu12, CUDA 13 for -cu13).
For this I think we want:
- matrices by CUDA major version, with the dependency spelled
cuda-toolkit[cusolver]==12.*andcuda-toolkit[cusolver]==13.* usa_cuda_wheelsguards, similar to https://github.com/rapidsai/cudf/blob/dda07069af24236c612dec623f471e946a6cdcfb/dependencies.yaml#L943-L962
The usa_cuda_wheels guards aren't strictly necessary since this project doesn't have devcontainers and isn't part of DLFW builds, but having the spelling be consistent with the rest of RAPIDS would make all-of-RAPIDS updates easier.
This is a good question -- I took another look at the failures and the tracebacks a little more closely and this is looking less like a From this run on #1116: https://github.com/rapidsai/cucim/actions/runs/29044082057/job/86214270820?pr=1116 ________ test_custom_eigvals_kernels_vs_linalg_eigvalsh[float32-shape1] ________
[gw4] linux -- Python 3.12.13 /pyenv/versions/3.12.13/bin/python
python/cucim/src/cucim/skimage/feature/tests/test_corner.py:351: in test_custom_eigvals_kernels_vs_linalg_eigvalsh
evs1 = _reference_eigvals_computation(H)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python/cucim/src/cucim/skimage/feature/tests/test_corner.py:338: in _reference_eigvals_computation
eigs = cp.linalg.eigvalsh(matrices)[..., ::-1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/pyenv/versions/3.12.13/lib/python3.12/site-packages/cupy/linalg/_eigenvalue.py:343: in eigvalsh
import cupyx.cusolver
E ImportError: libcusolver.so.12: cannot open shared object file: No such file or directory |
or alternatively, not a problem, just a mismatch. We have all of this wheel loading logic that prefers wheel installations over system installations, but because there CAN be a system installation, we don't fail loudly when we're missing DSOs in wheels. I wonder if all that's needed for |
or potentially even simpler, should we be installing the |
nope, we are already installing the |
Ok, this is a cupy bug, reporting upstream, then we can decide what to do here |
|
Reported upstream in cupy/cupy#10095, trying out temporary fixes involving |
|
Thanks for the careful review @jameslamb ! I wouldn't have thought I'd end up at |
cusolver if cupy is installed
|
Tested these changes here (obviously) and also in #1116 to demonstrate that |
jameslamb
left a comment
There was a problem hiding this comment.
Thanks so much for looking into those things I linked, I support the implementation you ended up with.
I read (and subscribed to) the cupy issue, great repo! Thanks for doing that.
It's a nice side benefit of using a slimmer test image, that we can catch issues like this in CI 🙂
Co-authored-by: Bradley Dice <bdice@bradleydice.com>
Co-authored-by: jakirkham <jakirkham@gmail.com>
jakirkham
left a comment
There was a problem hiding this comment.
Thanks Gil! 🙏
Have gone ahead and applied reasonable suggestions from here and the upstream issue. Hope that is ok.
LGTM
I'm testing out smaller base images for wheel testing in #1116 and those tests flagged up that we're missing a
cusolverdependency on wheel-only installs (the previous testing images have a full cuda toolkit installed beforehand).The missing dependency turns out to be due to a
cupybug upstream with wheel-only installs (reported in cupy/cupy#10095).This is a temporary workaround (if we want one) to enable switching to smaller test images (and also allowing end-users to use
cucimon wheel-only installs)xref rapidsai/build-planning#143
xref rapidsai/ci-imgs#400
xref rapidsai/shared-workflows#521