Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[BUG]: Program.compile("ptx") fails on machines without a CUDA driver, although NVRTC does not need one

Cerrado Apto para principiantes
#3,015 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
compilers

Línea de trabajo

Empieza en cuda/core/_program.pyx en _can_load_generated_ptx() (alrededor de la línea 815) y la rama cache-hit de Program.compile (~línea 1192); la llamada que lanza la excepción es driver_version() en cuda/core/_utils/version.pyx, que necesita libcuda. Captura DynamicLibNotFoundError y omite la advertencia de cargabilidad en lugar de fallar, replicando la ruta cubin. Reproduce con el fragmento en una máquina sin controlador y verifica las pruebas existentes del programa cuda.core; hecho significa que PTX se compila sin un controlador y una advertencia (o omisión silenciosa) reemplaza el error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

triage
Is this a duplicate?
Type of Bug

Runtime Error

Component

cuda.core

Describe the bug

On a Linux machine with no NVIDIA driver installed (a GitHub Actions ubuntu runner), compiling a Program to PTX with the NVRTC backend raises DynamicLibNotFoundError for libcuda.so.1. Compiling the same source to cubin with an explicit arch works on the same machine, so NVRTC itself is available.

The failure comes from the loadability check that runs before PTX compilation. _can_load_generated_ptx() calls driver_version(), which calls cuDriverGetVersion and needs libcuda. The check only decides whether to emit a RuntimeWarning, but when the driver library is missing it raises instead, and the whole compile fails. The same check is on the cache hit path in Program.compile.

This matters for CI jobs that compile kernels to PTX without a GPU, for example to inspect the generated PTX in tests. My workaround was to call cuda.bindings.nvrtc directly with the flags from ProgramOptions.as_bytes("nvrtc", "ptx"), which works without a driver.

How to Reproduce

On a machine without an NVIDIA driver. I used the ubuntu latest runner on GitHub Actions with Python 3.12.

pip install "cuda-core[cu12]==1.2.1"
from cuda.core import Program, ProgramOptions

src = 'extern "C" __global__ void k(float* x) { x[0] = 2.0f * x[0] + 1.0f; }'

# Works without a driver
Program(src, code_type="c++", options=ProgramOptions(arch="sm_75")).compile("cubin")

# Fails without a driver
Program(src, code_type="c++", options=ProgramOptions(arch="compute_75")).compile("ptx")

A public run on a runner with no libcuda shows both cases, the cubin compile passes and the ptx compile fails. https://github.com/VolodymyrLinuxovich/heat-risk-cuda/actions/runs/37217831804

Trimmed traceback from the failing run

cuda/core/_program.pyx:222: in cuda.core._program.Program.compile
cuda/core/_program.pyx:738: in cuda.core._program._program_compile_uncached
cuda/core/_program.pyx:1192: in cuda.core._program.Program_compile
cuda/core/_program.pyx:815: in cuda.core._program._can_load_generated_ptx
cuda/core/_utils/version.pyx:37: in cuda.core._utils.version.driver_version
cuda/bindings/driver.pyx:23154: in cuda.bindings.driver.cuDriverGetVersion
...
cuda.pathfinder._dynamic_libs.load_dl_common.DynamicLibNotFoundError: "cuda" is an NVIDIA driver library and can only be found via system search. Ensure the NVIDIA display driver is installed.

The _can_load_generated_ptx code on main looks the same as in 1.2.1, so I expect main behaves the same way, but I have only run 1.2.1.

Expected behavior

PTX compilation succeeds without a driver, the same as cubin compilation. When the driver version cannot be determined, the loadability check could skip the warning (or warn that loadability is unknown) instead of failing the compile.

I would be glad to open a PR for this if that approach sounds right to you.

Operating System

Ubuntu (GitHub Actions ubuntu latest runner), no NVIDIA driver

nvidia-smi output

Not available, no driver on that machine.

Lenguaje dominante
Cython
Estrellas
3.4k
Forks
334
Merge medio
1 d 17 h
PR fusionados (30 d)
136

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NVIDIA/cuda-python

Todos los issues de NVIDIA/cuda-python

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.