Skip to content

Commit 33ef7f8

Browse files
YLouWashUmeta-codesync[bot]
authored andcommitted
Add hasCudaSupport() runtime probe + Python has_cuda_support() API
Summary: This is D6 in the GPU-accelerated H.265 decoding stack for projectaria-tools (plan v11 at ~/gdrive/plans/2026-04-03-gpu-accelerated-h265-decoding-pat-v11.md, tech design at https://docs.google.com/document/d/1TMeLy0TqvAdlYo0IY3Qm4BrzE8i035z9MzYvGl_CzeM/edit by Lou Yang). Adds the user-facing `projectaria_tools.has_cuda_support()` API specified in the tech design. The Python helper lets users branch on GPU availability without crashing or guessing — typical use is picking a batch size, warning users about CPU fallback, or reporting environment info. Five files, bottom-up through the layers: 1. `arvr/projects/compression/xprs/xprs.h` — declares `bool hasCudaSupport()` with docstring explaining the runtime semantics. 2. `arvr/projects/compression/xprs/xprsDecApi.cpp` — implementation. Under `XPRS_HAS_NVDEC` it calls `NvCodecContextProvider::getNvCodecContext()` inside a try/catch and returns true iff init succeeds. Under no-NVDEC builds it returns false unconditionally. The first call drives the actual CUDA bring-up; subsequent calls hit the tri-state-atomic cache added in D3 (single atomic load on the fast path, no mutex contention). 3. `arvr/projects/ariane/aria_research_kit/projectaria_tools/core/python/XprsPyBind.h` — exports `has_cuda_support` on the existing xprs submodule with a Python-style docstring. 4. `arvr/projects/ariane/aria_research_kit/projectaria_tools/projectaria_tools/core/__init__.py` — adds `xprs` to the `from . import (...)` block. Without this, the convenience wrapper at the top-level `__init__.py` would raise `AttributeError: module 'projectaria_tools.core' has no attribute 'xprs'` because the `xprs` submodule wouldn't be imported into the `core` namespace. Discovered while testing the end-to-end Python invocation (see test plan item 6). 5. `arvr/projects/ariane/aria_research_kit/projectaria_tools/projectaria_tools/__init__.py` — re-exports as `projectaria_tools.has_cuda_support()` so users get the documented top-level API per the tech design. Reviewed By: PiotrBrzyski Differential Revision: D103253729 fbshipit-source-id: ea7320c561efcb504b8de51703fcf5380b2935f4
1 parent 560d061 commit 33ef7f8

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

core/python/XprsPyBind.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,23 @@ void declareXprsDecoding(py::module& module) {
143143

144144
inline void exportXprs(py::module& m) {
145145
declareXprsDecoding(m);
146+
147+
// Runtime probe so users can branch on GPU availability without crashing
148+
// the import. Returns true iff the wheel was built with NVDEC support AND
149+
// the CUDA driver is loadable on the current machine.
150+
m.def(
151+
"has_cuda_support",
152+
&xprs::hasCudaSupport,
153+
py::call_guard<py::gil_scoped_release>(),
154+
R"DOC(
155+
Returns True if NVIDIA NVDEC GPU-accelerated H.265 decoding is available
156+
in this process.
157+
158+
This is a runtime check that combines compile-time NVDEC availability with
159+
a successful CUDA driver load. The result is cached after the first call.
160+
On machines without an NVIDIA driver / GPU, returns False; PAT will silently
161+
fall back to the CPU decoder for all VRS reads.
162+
)DOC");
146163
}
147164

148165
} // namespace projectaria::tools::data_provider

projectaria_tools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414

1515
# This makes the modules discoverable when doing dir(projectaria_tools)
1616
from . import core # noqa
17+
from .core.xprs import has_cuda_support # noqa: F401

projectaria_tools/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
sophus,
2828
stream_id,
2929
vrs,
30+
xprs,
3031
)

0 commit comments

Comments
 (0)