[BUG]: Program.compile("ptx") fails on machines without a CUDA driver, although NVRTC does not need one
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 70/100
Piste de recherche
Commencez dans cuda/core/_program.pyx à _can_load_generated_ptx() (autour de la ligne 815) et la branche cache-hit de Program.compile (~ligne 1192) ; l'appel qui lève l'exception est driver_version() dans cuda/core/_utils/version.pyx, qui nécessite libcuda. Attrapez DynamicLibNotFoundError et ignorez l'avertissement de chargeabilité au lieu d'échouer, en reproduisant le chemin cubin. Reproduisez avec l'extrait sur une machine sans pilote et vérifiez les tests existants du programme cuda.core ; terminé signifie que PTX se compile sans pilote et qu'un avertissement (ou un saut silencieux) remplace l'erreur.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
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.
- Langage dominant
- Cython
- Étoiles
- 3.4k
- Forks
- 334
- Merge moyen
- 1 j 18 h
- PR mergées (30 j)
- 143
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NVIDIA/cuda-python
-
triage
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
NVIDIA/cuda-python#2952 ·
Les mainteneurs répondent en général sous 1 jour
-
[DOC]: cuda.core 1.1.1 note misstates program cache permissionsPeut-être pris @leofang l’a pris il y a 13 jours. Ouvertedocumentation P1
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
NVIDIA/cuda-python#2717 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[DOC]: `PinnedMemoryResource.allocate` documents no parametersPeut-être pris @Andy-Jost l’a pris il y a 13 jours. Ouvertecuda.core documentation P1
Difficulté 1/5 1-3 heures Accessibilité débutants 90/100
NVIDIA/cuda-python#2712 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookupPeut-être pris @rwgk l’a pris il y a 13 jours. Ouvertetriage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
NVIDIA/cuda-python#2646 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
[FEA]: Support inheritance from BufferPeut-être pris @leofang l’a pris il y a 13 jours. Ouvertecuda.core triage
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
NVIDIA/cuda-python#2435 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de NVIDIA/cuda-python
Issues similaires
-
erdos-status-sync
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
google-deepmind/formal-conjectures#6920 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
objectionary/eo#9317 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
rubys/roundhouse#571 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
anthropics/buffa#639 ·
Les mainteneurs répondent en général sous 3 jours
-
Module EQUIVALENCE into an array with a non-default lower bound ignores the bound (wrong element)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour