Skip to content

cuda.core: import fails with undefined symbol cudaGetErrorString when _tensor_map is built with -z now (after #2940) #3098

Open

Description

@Andy-Jost

Since #2940 reactivated _tensor_map on CCCL's <cuda/tma>, the extension references the CUDA runtime: cuda/__driver/entry_point.h calls cudaGetErrorString. _tensor_map is not linked against libcudart, and nothing in cuda.core loads cudart before cuda/core/__init__.py imports the module.

With the default flags of a pip build the reference is lazily bound and the import succeeds. With a toolchain that links with -Wl,-z,now, which the conda-forge compilers set in LDFLAGS, the extension carries BIND_NOW and every import cuda.core fails:

ImportError: .../cuda/core/_tensor_map.cpython-314-x86_64-linux-gnu.so: undefined symbol: cudaGetErrorString

Reproduction

Linux, conda-forge environment with Python 3.14, the CUDA 13.4 toolkit, and cuda-bindings 13.4.1; editable build of main.

  • readelf -d on the extension shows BIND_NOW and no libcudart entry under NEEDED.
  • nm -D --undefined-only lists cudaGetErrorString.
  • LD_PRELOAD=<env>/lib/libcudart.so.13 python -c "import cuda.core" succeeds; the plain import fails.

CI does not see this because its wheels are built with lazy binding. The conda-forge feedstock builds with the same compilers as the reproduction, so a conda package built from main would likely fail at import unless cudart is already loaded in the process.

Possible fixes

  • Load cudart before _tensor_map is imported, for example cuda.pathfinder.load_nvidia_dynamic_lib("cudart") at the top of _tensor_map.pyx. This also covers the lazy-binding case, where the symbol is first needed at run time.
  • Link _tensor_map against cudart in build_hooks.py.

Affects cuda_core/cuda/core/_tensor_map.pyx and cuda_core/build_hooks.py.

Activity

  1. added
    bugSomething isn't working
    P1Medium priority - Should do
    cuda.coreEverything related to the cuda.core module
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Medium priority - Should dobugSomething isn't workingcuda.coreEverything related to the cuda.core module

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions