preload PyPI nvidia-*-cu12 libs so _core.so resolves cuBLAS symbols#267
Merged
jameslehoux merged 1 commit intomasterfrom Apr 30, 2026
Merged
preload PyPI nvidia-*-cu12 libs so _core.so resolves cuBLAS symbols#267jameslehoux merged 1 commit intomasterfrom
jameslehoux merged 1 commit intomasterfrom
Conversation
Reported on Colab from a fresh `pip install openimpala-cuda`:
ImportError: .../openimpala/_core.cpython-312-...so:
undefined symbol: cublasSetStream_v2
The openimpala-cuda wheel auditwheel-excludes libcublas.so.12 (and
libcudart, libcusparse, libcurand, libnvJitLink) to fit under PyPI's
320 MiB cap, then declares the matching nvidia-*-cu12 packages as
runtime deps. Those PyPI wheels install their .so's under
``site-packages/nvidia/<component>/lib/``, which the dynamic linker
does NOT search by default — so when Python tries to load _core.so,
ld.so can't find libcublas.so.12 and the cuBLAS symbols stay
unresolved.
Fix mirrors what PyTorch, CuPy, and JAX all do: at the top of
openimpala/__init__.py, ctypes.CDLL each lib with RTLD_GLOBAL so its
symbols join the global namespace before any compiled extension
import. Try the bare soname first (so HPC nodes with system CUDA on
LD_LIBRARY_PATH win) and fall back to the PyPI bundled path if not
found.
Load order matters:
- libcudart.so.12 first (most CUDA libs depend on it)
- libnvJitLink.so.12
- libcublasLt.so.12 BEFORE libcublas.so.12 (cublas links against
cublasLt at the symbol level)
- libcusparse.so.12, libcurand.so.10
No-op on the pure-Python wheel (the nvidia/ site-packages dir doesn't
exist) and on non-Linux platforms (sys.platform check).
https://claude.ai/code/session_011dJ5Bwq4Tnr8wxH597XJFf
Performance Benchmark Results
Fastest solver: bicgstab at 64³ (0.3723s) Benchmark: uniform block (analytical τ = (N-1)/N) |
Code Coverage ReportGenerated by CI — coverage data from gcovr |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported on Colab from a fresh
pip install openimpala-cuda:The openimpala-cuda wheel auditwheel-excludes libcublas.so.12 (and libcudart, libcusparse, libcurand, libnvJitLink) to fit under PyPI's 320 MiB cap, then declares the matching nvidia-*-cu12 packages as runtime deps. Those PyPI wheels install their .so's under
site-packages/nvidia/<component>/lib/, which the dynamic linker does NOT search by default — so when Python tries to load _core.so, ld.so can't find libcublas.so.12 and the cuBLAS symbols stay unresolved.Fix mirrors what PyTorch, CuPy, and JAX all do: at the top of openimpala/init.py, ctypes.CDLL each lib with RTLD_GLOBAL so its symbols join the global namespace before any compiled extension import. Try the bare soname first (so HPC nodes with system CUDA on LD_LIBRARY_PATH win) and fall back to the PyPI bundled path if not found.
Load order matters:
No-op on the pure-Python wheel (the nvidia/ site-packages dir doesn't exist) and on non-Linux platforms (sys.platform check).