Skip to content

Commit 01cfed6

Browse files
YLouWashUmeta-codesync[bot]
authored andcommitted
{Feature} CUDA Decoding - Enable NVDEC in cibuildwheel and harden wheel test (#386)
Summary: Pull Request resolved: #386 Builds the Linux x86_64 `projectaria_tools` wheels with NVDEC GPU H.265 decode enabled, and hardens the in-CI wheel test to lock in the CUDA-agnostic guarantee. Applied to both `build-wheels-and-deploy.yml` and `test-for-build-wheels.yml`: - ubuntu cibuildwheel step: `CIBW_ENVIRONMENT_LINUX="PROJECTARIA_ENABLE_CUDA=1"` (turns on `-DENABLE_NVCODEC=ON` via `setup.py`; the build needs only `nv-codec-headers` installed by the prior diff, no GPU or CUDA toolkit). macOS wheels are unaffected -- NVDEC is Linux-only. - `CIBW_REPAIR_WHEEL_COMMAND_LINUX` adds `auditwheel repair --exclude libcuda.so.1 --exclude libnvcuvid.so.1` so the driver libs are never vendored into the wheel (they are dlopen'd at runtime). - Test wheel step: runs `has_cuda_support()` (returns False on the no-GPU runner) and, on Linux, asserts the built `_core_pybinds` extension has no `libcuda`/`libnvcuvid` in `DT_NEEDED`. GPU decode itself cannot be exercised in CI (GitHub runners have no NVIDIA GPU); it is validated manually on a GPU machine against the CI-built / TestPyPI wheel (shipping plan Stage 3.5 / 4). Reviewed By: kongchen1992 Differential Revision: D114393583 fbshipit-source-id: f115f10f8e3c2340517f01d085754d1bcc041eb7
1 parent 9316cc7 commit 01cfed6

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/build-wheels-and-deploy.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ jobs:
149149
CIBW_BUILD_VERBOSITY: 3
150150
CIBW_BUILD: ${{ matrix.cibw_build }}
151151
CIBW_BEFORE_BUILD_LINUX: bash build_third_party_libs/install_manylinux_deps.sh
152+
# Enable NVDEC GPU H.265 decode in Linux x86_64 wheels. The build needs
153+
# only nv-codec-headers (installed by install_manylinux_deps.sh), not a
154+
# GPU or CUDA toolkit; the wheel stays CUDA-agnostic.
155+
CIBW_ENVIRONMENT_LINUX: "PROJECTARIA_ENABLE_CUDA=1"
156+
# libcuda/libnvcuvid are dlopen'd from the driver at runtime and must
157+
# never be vendored into the wheel; exclude them from auditwheel repair.
158+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --exclude libcuda.so.1 --exclude libnvcuvid.so.1 -w {dest_dir} {wheel}"
152159
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
153160
CIBW_ARCHS: "x86_64"
154161
- name: Build wheels for CPython
@@ -176,6 +183,19 @@ jobs:
176183
export TEST_FOLDER_GEN2="./data/gen2/"
177184
python -m unittest core/python/test/corePyBindTest.py
178185
python -m unittest core/python/test/mpsPyBindTest.py
186+
# CUDA-agnostic checks. Runners have no GPU, so has_cuda_support() is
187+
# expected to return False here; the point is that it runs without a
188+
# CUDA install, and the Linux wheel links no CUDA libraries (they are
189+
# dlopen'd from the driver at runtime, never bundled).
190+
python -c "import projectaria_tools as t; print('has_cuda_support:', t.has_cuda_support())"
191+
if [ "$RUNNER_OS" == "Linux" ]; then
192+
CORE_SO=$(python -c "import _core_pybinds; print(_core_pybinds.__file__)")
193+
echo "Checking $CORE_SO for CUDA linkage"
194+
if readelf -d "$CORE_SO" | grep NEEDED | grep -iE 'libcuda|libnvcuvid'; then
195+
echo "ERROR: wheel links CUDA libraries; it must be CUDA-agnostic" && exit 1
196+
fi
197+
echo "OK: no CUDA libraries in NEEDED"
198+
fi
179199
180200
publish-to-pypi:
181201
name: Publish to Pypi

.github/workflows/test-for-build-wheels.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ jobs:
131131
CIBW_BUILD_VERBOSITY: 3
132132
CIBW_BUILD: ${{ matrix.cibw_build }}
133133
CIBW_BEFORE_BUILD_LINUX: bash build_third_party_libs/install_manylinux_deps.sh
134+
# Enable NVDEC GPU H.265 decode in Linux x86_64 wheels. The build needs
135+
# only nv-codec-headers (installed by install_manylinux_deps.sh), not a
136+
# GPU or CUDA toolkit; the wheel stays CUDA-agnostic.
137+
CIBW_ENVIRONMENT_LINUX: "PROJECTARIA_ENABLE_CUDA=1"
138+
# libcuda/libnvcuvid are dlopen'd from the driver at runtime and must
139+
# never be vendored into the wheel; exclude them from auditwheel repair.
140+
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --exclude libcuda.so.1 --exclude libnvcuvid.so.1 -w {dest_dir} {wheel}"
134141
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
135142
CIBW_ARCHS: "x86_64"
136143
- name: Build wheels for CPython
@@ -158,3 +165,16 @@ jobs:
158165
export TEST_FOLDER_GEN2="./data/gen2/"
159166
python -m unittest core/python/test/corePyBindTest.py
160167
python -m unittest core/python/test/mpsPyBindTest.py
168+
# CUDA-agnostic checks. Runners have no GPU, so has_cuda_support() is
169+
# expected to return False here; the point is that it runs without a
170+
# CUDA install, and the Linux wheel links no CUDA libraries (they are
171+
# dlopen'd from the driver at runtime, never bundled).
172+
python -c "import projectaria_tools as t; print('has_cuda_support:', t.has_cuda_support())"
173+
if [ "$RUNNER_OS" == "Linux" ]; then
174+
CORE_SO=$(python -c "import _core_pybinds; print(_core_pybinds.__file__)")
175+
echo "Checking $CORE_SO for CUDA linkage"
176+
if readelf -d "$CORE_SO" | grep NEEDED | grep -iE 'libcuda|libnvcuvid'; then
177+
echo "ERROR: wheel links CUDA libraries; it must be CUDA-agnostic" && exit 1
178+
fi
179+
echo "OK: no CUDA libraries in NEEDED"
180+
fi

0 commit comments

Comments
 (0)