pytest-gpu-proof 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/.github/workflows/ci.yml +1 -1
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/CHANGELOG.md +12 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/CONTRIBUTING.md +1 -1
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/PKG-INFO +4 -3
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/README.md +1 -1
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/architecture.md +3 -1
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/pyproject.toml +3 -2
- pytest_gpu_proof-0.5.1/src/pytest_gpu_proof/__init__.py +1 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/plugin.py +4 -2
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/receipt.py +65 -2
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_plugin_capture.py +27 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_receipt.py +84 -0
- pytest_gpu_proof-0.5.0/src/pytest_gpu_proof/__init__.py +0 -1
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/.github/workflows/docs.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/.github/workflows/publish-testpypi.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/.github/workflows/publish.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/.gitignore +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/AGENTS.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/CLAUDE.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/LICENSE +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/RELEASING.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/ROADMAP.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/SECURITY.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/ci_gpu_mode.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/index.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/landscape.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/local_mode.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/policy.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/quickstart.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/security_model.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/docs/sharding.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/Makefile +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/README.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/test_cuda_ctypes_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/README.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/bindings.cpp +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_cuda.h +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/test_cuda_nanobind_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/README.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/bindings.cpp +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_cuda.h +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/test_cuda_pybind11_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/github_gpu_runner/.github/workflows/gpu-test.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/CMakeLists.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/README.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/test_jax_ffi_cuda_matmul.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/local_receipt_verify/.github/workflows/verify.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/conftest.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/test_minimal.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/install.sh +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/mkdocs.yml +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/requirements-dev.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/requirements.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/__main__.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/cli.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/compare.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/config.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/fingerprint.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/gitutils.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/merge.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/__init__.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/base.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/signers/ed25519.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/src/pytest_gpu_proof/verify.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/conftest.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_cli.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_compare.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_config.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_fingerprint.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_gitutils.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_merge.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_sharding.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_signing.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/tests/test_verifier.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/README.md +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/build_site.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/check_site.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/favicon.svg +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/index.html +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/main.js +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/overrides/main.html +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/provenance.json +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/requirements.txt +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/style.css +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/test_site.py +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/workflow-mobile.svg +0 -0
- {pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/website/workflow.svg +0 -0
|
@@ -4,6 +4,18 @@ All notable changes to pytest-gpu-proof are documented here. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/); versions follow
|
|
5
5
|
[SemVer](https://semver.org/) (pre-1.0: minor bumps may break).
|
|
6
6
|
|
|
7
|
+
## [0.5.1] — 2026-11-03
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Python 3.9 support (the oldest Python on a JetPack 5 Jetson), with a CI test
|
|
12
|
+
lane. The code already avoided 3.10-only syntax; only the floor moved.
|
|
13
|
+
- `environment.gpu_info` and the `gpu_required` probe fall back to the CUDA
|
|
14
|
+
driver library (`libcuda` through `ctypes`) when neither `nvidia-smi` nor
|
|
15
|
+
PyTorch is available, as on Jetson boards before JetPack 7. The record names
|
|
16
|
+
its source (`nvidia-smi`, `torch`, or `libcuda`) and stays self-reported
|
|
17
|
+
metadata, not evidence of execution.
|
|
18
|
+
|
|
7
19
|
## [0.5.0] — 2026-10-28
|
|
8
20
|
|
|
9
21
|
### Added
|
|
@@ -19,7 +19,7 @@ python -m build
|
|
|
19
19
|
python -m twine check --strict dist/*
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
CI runs the test suite on Python 3.10, 3.11, 3.12, and 3.13, independently enforces
|
|
22
|
+
CI runs the test suite on Python 3.9, 3.10, 3.11, 3.12, and 3.13, independently enforces
|
|
23
23
|
100% line and branch coverage, builds docs strictly, and smoke-tests the wheel.
|
|
24
24
|
|
|
25
25
|
## Change expectations
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-gpu-proof
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys
|
|
5
5
|
Project-URL: Homepage, https://a2r-lab.org/pytest-gpu-proof/
|
|
6
6
|
Project-URL: Documentation, https://a2r-lab.org/pytest-gpu-proof/docs/
|
|
@@ -16,13 +16,14 @@ Classifier: Intended Audience :: Developers
|
|
|
16
16
|
Classifier: License :: OSI Approved :: MIT License
|
|
17
17
|
Classifier: Operating System :: OS Independent
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
21
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
22
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
23
24
|
Classifier: Topic :: Security :: Cryptography
|
|
24
25
|
Classifier: Topic :: Software Development :: Testing
|
|
25
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.9
|
|
26
27
|
Requires-Dist: cryptography>=41.0
|
|
27
28
|
Requires-Dist: pytest>=7.0
|
|
28
29
|
Requires-Dist: tomli>=2.0; python_version < '3.11'
|
|
@@ -156,7 +157,7 @@ a map that shard bin-packers can calibrate from.
|
|
|
156
157
|
|---|---|
|
|
157
158
|
| `@pytest.mark.gpu_proof` | Include the test in the receipt |
|
|
158
159
|
| `@pytest.mark.gpu_equivalence` | Alias for `gpu_proof` |
|
|
159
|
-
| `@pytest.mark.gpu_required` | Skip when
|
|
160
|
+
| `@pytest.mark.gpu_required` | Skip when none of `nvidia-smi`, PyTorch, or the CUDA driver library (`libcuda` through `ctypes`) reports a GPU |
|
|
160
161
|
|
|
161
162
|
Skipped tests are recorded. Verification rejects them by default. Prefer an
|
|
162
163
|
exact `--expected-skips` baseline over the broad `--allow-skipped` escape
|
|
@@ -116,7 +116,7 @@ a map that shard bin-packers can calibrate from.
|
|
|
116
116
|
|---|---|
|
|
117
117
|
| `@pytest.mark.gpu_proof` | Include the test in the receipt |
|
|
118
118
|
| `@pytest.mark.gpu_equivalence` | Alias for `gpu_proof` |
|
|
119
|
-
| `@pytest.mark.gpu_required` | Skip when
|
|
119
|
+
| `@pytest.mark.gpu_required` | Skip when none of `nvidia-smi`, PyTorch, or the CUDA driver library (`libcuda` through `ctypes`) reports a GPU |
|
|
120
120
|
|
|
121
121
|
Skipped tests are recorded. Verification rejects them by default. Prefer an
|
|
122
122
|
exact `--expected-skips` baseline over the broad `--allow-skipped` escape
|
|
@@ -52,7 +52,9 @@ The top-level blocks are:
|
|
|
52
52
|
- `fingerprint`: manifest algorithm, tracked paths, extra paths, count, digest;
|
|
53
53
|
- `session`: start/end, pass/fail, exact node IDs, pytest arguments;
|
|
54
54
|
- `tests`: terminal outcome, phase, duration, and comparison checks;
|
|
55
|
-
- `environment`: Python, platform, pytest, plugin, and self-reported GPU data
|
|
55
|
+
- `environment`: Python, platform, pytest, plugin, and self-reported GPU data
|
|
56
|
+
(from `nvidia-smi`, else PyTorch, else the CUDA driver library through `ctypes`;
|
|
57
|
+
`gpu_info.source` names which);
|
|
56
58
|
- `shards`: optional narrow manifests and carry metadata;
|
|
57
59
|
- `signer`: signed username, algorithm, backend, and key fingerprint;
|
|
58
60
|
- `signature`: base64 signature value only.
|
|
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pytest-gpu-proof"
|
|
7
|
-
version = "0.5.
|
|
7
|
+
version = "0.5.1"
|
|
8
8
|
description = "pytest plugin for GPU equivalence testing with signed receipts verified via GitHub SSH keys"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
11
|
license = { text = "MIT" }
|
|
12
12
|
keywords = ["pytest", "gpu", "cuda", "testing", "signing", "attestation"]
|
|
13
13
|
classifiers = [
|
|
@@ -17,6 +17,7 @@ classifiers = [
|
|
|
17
17
|
"License :: OSI Approved :: MIT License",
|
|
18
18
|
"Operating System :: OS Independent",
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
20
21
|
"Programming Language :: Python :: 3.10",
|
|
21
22
|
"Programming Language :: Python :: 3.11",
|
|
22
23
|
"Programming Language :: Python :: 3.12",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.1"
|
|
@@ -30,10 +30,12 @@ def _has_gpu() -> bool:
|
|
|
30
30
|
pass
|
|
31
31
|
try:
|
|
32
32
|
import torch
|
|
33
|
-
|
|
33
|
+
if torch.cuda.is_available():
|
|
34
|
+
return True
|
|
34
35
|
except ImportError:
|
|
35
36
|
pass
|
|
36
|
-
|
|
37
|
+
from .receipt import _gpu_info_from_libcuda
|
|
38
|
+
return _gpu_info_from_libcuda(include_uuid=False) is not None
|
|
37
39
|
|
|
38
40
|
|
|
39
41
|
class GpuProofPlugin:
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import base64
|
|
6
|
+
import ctypes
|
|
6
7
|
import datetime
|
|
7
8
|
import json
|
|
8
9
|
import os
|
|
@@ -10,6 +11,7 @@ import platform
|
|
|
10
11
|
import subprocess
|
|
11
12
|
import sys
|
|
12
13
|
import tempfile
|
|
14
|
+
import uuid
|
|
13
15
|
from pathlib import Path
|
|
14
16
|
from typing import Any, Dict, List, Optional
|
|
15
17
|
|
|
@@ -56,6 +58,67 @@ def _gpu_info_from_torch() -> Optional[Dict[str, Any]]:
|
|
|
56
58
|
"source": "torch"}
|
|
57
59
|
|
|
58
60
|
|
|
61
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR = 75
|
|
62
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR = 76
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _gpu_info_from_libcuda(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
66
|
+
"""nvidia-smi-free, torch-free fallback through the CUDA driver API: ctypes
|
|
67
|
+
on libcuda. Jetson boards before JetPack 7 ship no nvidia-smi, and a plain
|
|
68
|
+
pytest venv there has no torch, so without this a Jetson receipt records
|
|
69
|
+
`gpu_info: null` and fails `require_gpu` for the wrong reason. Still
|
|
70
|
+
self-reported metadata, like the other two sources."""
|
|
71
|
+
try:
|
|
72
|
+
cuda = ctypes.CDLL("libcuda.so.1")
|
|
73
|
+
except OSError:
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
def call(name: str, *args: Any) -> None:
|
|
77
|
+
rc = getattr(cuda, name)(*args)
|
|
78
|
+
if rc != 0:
|
|
79
|
+
raise OSError(f"{name} returned CUresult {rc}")
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
call("cuInit", 0)
|
|
83
|
+
count = ctypes.c_int()
|
|
84
|
+
call("cuDeviceGetCount", ctypes.byref(count))
|
|
85
|
+
driver = ctypes.c_int()
|
|
86
|
+
call("cuDriverGetVersion", ctypes.byref(driver))
|
|
87
|
+
driver_version = f"{driver.value // 1000}.{(driver.value % 1000) // 10}"
|
|
88
|
+
devices = []
|
|
89
|
+
for index in range(count.value):
|
|
90
|
+
device = ctypes.c_int()
|
|
91
|
+
call("cuDeviceGet", ctypes.byref(device), index)
|
|
92
|
+
name = ctypes.create_string_buffer(256)
|
|
93
|
+
call("cuDeviceGetName", name, 256, device)
|
|
94
|
+
major, minor = ctypes.c_int(), ctypes.c_int()
|
|
95
|
+
call("cuDeviceGetAttribute", ctypes.byref(major),
|
|
96
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device)
|
|
97
|
+
call("cuDeviceGetAttribute", ctypes.byref(minor),
|
|
98
|
+
_CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device)
|
|
99
|
+
total = ctypes.c_size_t()
|
|
100
|
+
call("cuDeviceTotalMem_v2", ctypes.byref(total), device)
|
|
101
|
+
device_uuid = None
|
|
102
|
+
if include_uuid:
|
|
103
|
+
raw = ctypes.create_string_buffer(16)
|
|
104
|
+
call("cuDeviceGetUuid", raw, device)
|
|
105
|
+
device_uuid = f"GPU-{uuid.UUID(bytes=raw.raw)}"
|
|
106
|
+
devices.append({
|
|
107
|
+
"index": str(index),
|
|
108
|
+
"uuid": device_uuid,
|
|
109
|
+
"name": name.value.decode("utf-8", "replace"),
|
|
110
|
+
"driver_version": driver_version,
|
|
111
|
+
"memory": f"{total.value // (1024 * 1024)} MiB",
|
|
112
|
+
"compute_capability": f"{major.value}.{minor.value}",
|
|
113
|
+
})
|
|
114
|
+
except (AttributeError, OSError): # missing symbol, failed driver call
|
|
115
|
+
return None
|
|
116
|
+
if not devices:
|
|
117
|
+
return None
|
|
118
|
+
return {"devices": devices, "cuda_visible_devices": os.environ.get("CUDA_VISIBLE_DEVICES"),
|
|
119
|
+
"source": "libcuda"}
|
|
120
|
+
|
|
121
|
+
|
|
59
122
|
def _gpu_info(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
60
123
|
try:
|
|
61
124
|
result = subprocess.run(
|
|
@@ -69,9 +132,9 @@ def _gpu_info(include_uuid: bool = True) -> Optional[Dict[str, Any]]:
|
|
|
69
132
|
timeout=10,
|
|
70
133
|
)
|
|
71
134
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
|
72
|
-
return _gpu_info_from_torch()
|
|
135
|
+
return _gpu_info_from_torch() or _gpu_info_from_libcuda(include_uuid)
|
|
73
136
|
if result.returncode != 0 or not result.stdout.strip():
|
|
74
|
-
return _gpu_info_from_torch()
|
|
137
|
+
return _gpu_info_from_torch() or _gpu_info_from_libcuda(include_uuid)
|
|
75
138
|
devices = []
|
|
76
139
|
for line in result.stdout.splitlines():
|
|
77
140
|
parts = [part.strip() for part in line.split(",")]
|
|
@@ -455,6 +455,31 @@ def test_has_gpu_fallbacks(monkeypatch):
|
|
|
455
455
|
raise ImportError
|
|
456
456
|
return real_import(name, *args, **kwargs)
|
|
457
457
|
monkeypatch.setattr(builtins, "__import__", no_torch)
|
|
458
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
459
|
+
lambda include_uuid=True: None)
|
|
460
|
+
assert plugin_module._has_gpu() is False
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
def test_has_gpu_falls_back_to_libcuda(monkeypatch):
|
|
464
|
+
"""2026-11-02: the marker probe and the receipt share the libcuda fallback,
|
|
465
|
+
so a Jetson without nvidia-smi or torch neither skips gpu_required tests
|
|
466
|
+
nor records gpu_info: null."""
|
|
467
|
+
import subprocess
|
|
468
|
+
from types import SimpleNamespace
|
|
469
|
+
|
|
470
|
+
monkeypatch.setattr(subprocess, "run", lambda *a, **k: subprocess.CompletedProcess([], 1))
|
|
471
|
+
monkeypatch.setitem(__import__("sys").modules, "torch",
|
|
472
|
+
SimpleNamespace(cuda=SimpleNamespace(is_available=lambda: False)))
|
|
473
|
+
seen = []
|
|
474
|
+
|
|
475
|
+
def probe(include_uuid=True):
|
|
476
|
+
seen.append(include_uuid)
|
|
477
|
+
return {"devices": [{"index": "0"}], "cuda_visible_devices": None, "source": "libcuda"}
|
|
478
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda", probe)
|
|
479
|
+
assert plugin_module._has_gpu() is True
|
|
480
|
+
assert seen == [False]
|
|
481
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
482
|
+
lambda include_uuid=True: None)
|
|
458
483
|
assert plugin_module._has_gpu() is False
|
|
459
484
|
|
|
460
485
|
|
|
@@ -517,6 +542,8 @@ def test_has_gpu_handles_nvidia_error(monkeypatch):
|
|
|
517
542
|
raise ImportError
|
|
518
543
|
return real_import(name, *args, **kwargs)
|
|
519
544
|
monkeypatch.setattr(builtins, "__import__", no_torch)
|
|
545
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
546
|
+
lambda include_uuid=True: None)
|
|
520
547
|
assert plugin_module._has_gpu() is False
|
|
521
548
|
|
|
522
549
|
|
|
@@ -110,6 +110,8 @@ def test_gpu_capture_unavailable(monkeypatch, behavior):
|
|
|
110
110
|
monkeypatch.setattr(
|
|
111
111
|
"pytest_gpu_proof.receipt.subprocess.run", lambda *a, **k: behavior()
|
|
112
112
|
)
|
|
113
|
+
monkeypatch.setattr("pytest_gpu_proof.receipt._gpu_info_from_libcuda",
|
|
114
|
+
lambda include_uuid=True: None)
|
|
113
115
|
assert _gpu_info() is None
|
|
114
116
|
|
|
115
117
|
|
|
@@ -313,6 +315,7 @@ def test_gpu_info_falls_back_to_torch_when_nvidia_smi_is_absent(monkeypatch):
|
|
|
313
315
|
def no_smi(*args, **kwargs):
|
|
314
316
|
raise FileNotFoundError("nvidia-smi")
|
|
315
317
|
monkeypatch.setattr(receipt_mod.subprocess, "run", no_smi)
|
|
318
|
+
monkeypatch.setattr(receipt_mod, "_gpu_info_from_libcuda", lambda include_uuid=True: None)
|
|
316
319
|
props = types.SimpleNamespace(name="Fake GPU", total_memory=8 * 1024 ** 3, major=12, minor=0)
|
|
317
320
|
fake_cuda = types.SimpleNamespace(is_available=lambda: True, device_count=lambda: 1,
|
|
318
321
|
get_device_properties=lambda i: props)
|
|
@@ -338,6 +341,87 @@ def test_gpu_info_falls_back_to_torch_on_nvidia_smi_failure(monkeypatch):
|
|
|
338
341
|
monkeypatch.setattr(receipt_mod.subprocess, "run",
|
|
339
342
|
lambda *a, **k: types.SimpleNamespace(returncode=1, stdout=""))
|
|
340
343
|
monkeypatch.setitem(sys.modules, "torch", None)
|
|
344
|
+
monkeypatch.setattr(receipt_mod, "_gpu_info_from_libcuda", lambda include_uuid=True: None)
|
|
345
|
+
assert receipt_mod._gpu_info() is None
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
class _FakeLibcuda:
|
|
349
|
+
"""Stand-in for ctypes.CDLL('libcuda.so.1'): every entry point writes the
|
|
350
|
+
canned answer into its ctypes out-argument and returns CUDA_SUCCESS, except
|
|
351
|
+
`fail`, which returns a nonzero CUresult, and `missing`, which is absent."""
|
|
352
|
+
|
|
353
|
+
def __init__(self, count=1, fail=None, missing=None):
|
|
354
|
+
self.count, self.fail, self.missing = count, fail, missing
|
|
355
|
+
|
|
356
|
+
def __getattr__(self, name):
|
|
357
|
+
if name == self.missing:
|
|
358
|
+
raise AttributeError(name)
|
|
359
|
+
|
|
360
|
+
def entry(*args):
|
|
361
|
+
if name == self.fail:
|
|
362
|
+
return 999
|
|
363
|
+
if name == "cuDeviceGetCount":
|
|
364
|
+
args[0]._obj.value = self.count
|
|
365
|
+
elif name == "cuDriverGetVersion":
|
|
366
|
+
args[0]._obj.value = 13020
|
|
367
|
+
elif name == "cuDeviceGet":
|
|
368
|
+
args[0]._obj.value = args[1]
|
|
369
|
+
elif name == "cuDeviceGetName":
|
|
370
|
+
args[0].value = b"Fake Orin"
|
|
371
|
+
elif name == "cuDeviceGetAttribute":
|
|
372
|
+
args[0]._obj.value = {75: 8, 76: 7}[args[1]]
|
|
373
|
+
elif name == "cuDeviceTotalMem_v2":
|
|
374
|
+
args[0]._obj.value = 62878 * 1024 * 1024
|
|
375
|
+
elif name == "cuDeviceGetUuid":
|
|
376
|
+
args[0].raw = bytes(range(16))
|
|
377
|
+
return 0
|
|
378
|
+
return entry
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def _no_smi_no_torch(monkeypatch, receipt_mod):
|
|
382
|
+
import sys
|
|
383
|
+
|
|
384
|
+
def no_smi(*args, **kwargs):
|
|
385
|
+
raise FileNotFoundError("nvidia-smi")
|
|
386
|
+
monkeypatch.setattr(receipt_mod.subprocess, "run", no_smi)
|
|
387
|
+
monkeypatch.setitem(sys.modules, "torch", None)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def test_gpu_info_falls_back_to_libcuda(monkeypatch):
|
|
391
|
+
"""2026-11-02: a Jetson before JetPack 7 has no nvidia-smi and a plain venv
|
|
392
|
+
has no torch; the CUDA driver library still identifies the device."""
|
|
393
|
+
from pytest_gpu_proof import receipt as receipt_mod
|
|
394
|
+
_no_smi_no_torch(monkeypatch, receipt_mod)
|
|
395
|
+
monkeypatch.setattr(receipt_mod.ctypes, "CDLL", lambda name: _FakeLibcuda(count=2))
|
|
396
|
+
monkeypatch.setenv("CUDA_VISIBLE_DEVICES", "0")
|
|
397
|
+
info = receipt_mod._gpu_info()
|
|
398
|
+
assert info["source"] == "libcuda"
|
|
399
|
+
assert info["cuda_visible_devices"] == "0"
|
|
400
|
+
assert info["devices"][0] == {
|
|
401
|
+
"index": "0", "uuid": "GPU-00010203-0405-0607-0809-0a0b0c0d0e0f", "name": "Fake Orin",
|
|
402
|
+
"driver_version": "13.2", "memory": "62878 MiB", "compute_capability": "8.7"}
|
|
403
|
+
assert info["devices"][1]["index"] == "1"
|
|
404
|
+
anonymous = receipt_mod._gpu_info(include_uuid=False)
|
|
405
|
+
assert [d["uuid"] for d in anonymous["devices"]] == [None, None]
|
|
406
|
+
assert anonymous["devices"][0]["name"] == "Fake Orin"
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
@pytest.mark.parametrize("fake", [
|
|
410
|
+
None, # libcuda.so.1 not loadable
|
|
411
|
+
_FakeLibcuda(fail="cuInit"), # a driver call fails
|
|
412
|
+
_FakeLibcuda(fail="cuDeviceGetUuid"), # a per-device call fails
|
|
413
|
+
_FakeLibcuda(missing="cuDeviceGetName"), # symbol absent from the library
|
|
414
|
+
_FakeLibcuda(count=0), # driver loads, no device
|
|
415
|
+
])
|
|
416
|
+
def test_gpu_info_libcuda_fallback_fails_closed(monkeypatch, fake):
|
|
417
|
+
from pytest_gpu_proof import receipt as receipt_mod
|
|
418
|
+
_no_smi_no_torch(monkeypatch, receipt_mod)
|
|
419
|
+
|
|
420
|
+
def load(name):
|
|
421
|
+
if fake is None:
|
|
422
|
+
raise OSError(f"{name}: cannot open shared object file")
|
|
423
|
+
return fake
|
|
424
|
+
monkeypatch.setattr(receipt_mod.ctypes, "CDLL", load)
|
|
341
425
|
assert receipt_mod._gpu_info() is None
|
|
342
426
|
|
|
343
427
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/cuda_ctypes_matmul.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_ctypes_matmul/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/bindings.cpp
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_cuda.h
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_nanobind_matmul/src/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/bindings.cpp
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_cuda.h
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/cuda_pybind11_matmul/src/matmul_kernel.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/jax_ffi_matmul.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/jax_ffi_cuda_matmul/src/matmul_ffi.cu
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/minimal_python_only/test_minimal.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/fake_cuda_lib.py
RENAMED
|
File without changes
|
{pytest_gpu_proof-0.5.0 → pytest_gpu_proof-0.5.1}/examples/wrapped_cuda_ctypes/test_cuda_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|