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

Aberta
#3,098 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

  • #3104 de @seberg — fechado sem integrar

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
45/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
build-system

Direção de pesquisa

The failing symbol comes in through cuda/__driver/entry_point.h, and the extension is built from cuda_core/cuda/core/_tensor_map.pyx with settings in cuda_core/build_hooks.py. Reproduce by building with -Wl,-z,now, then check the result with readelf -d for BIND_NOW and nm -D --undefined-only for cudaGetErrorString. Choose between loading cudart at the top of _tensor_map.pyx or linking it in build_hooks.py. Done when import cuda.core succeeds under -z now without LD_PRELOAD, and the default lazy build still works.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug cuda.core P1

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.

Linguagem predominante
Cython
Estrelas
3.4k
Forks
353
Merge médio
2d 3h
PRs com merge (30d)
163

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NVIDIA/cuda-python

Todas as issues de NVIDIA/cuda-python

Issues semelhantes

Mais issues de Build System

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.